scpoecon / scpoeconometrics Goto Github PK
View Code? Open in Web Editor NEWUndergraduate textbook for Econometrics with R
Home Page: https://ScPoEcon.github.io/ScPoEconometrics/
License: Other
Undergraduate textbook for Econometrics with R
Home Page: https://ScPoEcon.github.io/ScPoEconometrics/
License: Other
On R version 3.4.4 (2018-03-15)
I've loaded the libraries ScPoEconometrics 0.0.1 and learner 0.9.2.1.
When running:
run_tutorial("chapter3",package="ScPoEconometrics")
I obtain:
Listening on http://127.0.0.1:7177
Warning: Error in value[[3L]]: Couldn't normalize path inaddResourcePath
, with arguments:prefix
= 'font-awesome-4.5.0';directoryPath
= '' [No stack trace available]
Related to the following issue:
https://stackoverflow.com/questions/51213726/when-running-a-tutorial-with-learnr-r-gives-an-error
is imcomplete! chapter 4.
in SSR_cone app the x-y axis should be "intercept" and "slope" not a_ and b_
No book build but run tests
it's always confusing for students to think about what happens when one transforms on of the vars in a regression
i am not thinking about log transforms for now
just say that we multiply both y and x with a constant c. what happens to a and b?
what if only x?
what if only y?
if you have simple way to show the log-log model, make a proposal, otherwise let's disregard this for now.
potential topic
_build.sh
copy slides into _book
directorylibrary(mvtnorm)
set.seed(10)
cor = 0.9
sig = matrix(c(1,cor,cor,1),c(2,2))
ndat = data.frame(rmvnorm(n=300,sigma = sig))
x = ndat$X1
y = ndat$X2
par(pty="s")
plot(x ~ y, xlab="x",ylab="y")
and move cor
TODO:
table
function which is not introduced anywhere else in the book... Maybe let's keep it to teach them the virtue of figuring things out by yourself?/inst/shinys/reg1
for the first regapp/inst/shinys/reg2
for the second and so onlm
to finish off the simple reg_app sectionEcdat
R CMD CHECK
removes unncessary files.x - mean(x)
, same for y.currently you do
rect(xleft = x, ybottom = y,
xright = x + abs(errors), ytop = y + errors, density = -1,
col = rgb(red = 0, green = 1, blue = 0, alpha = 0.1), border = NA)
I find it nicer like this:
rect(xleft = x, ybottom = y,
xright = x + abs(errors), ytop = y - errors, density = -1,
col = rgb(red = 0, green = 1, blue = 0, alpha = 0.1), border = NA)
(just swap the sign in front of errors
for y
.
this will have rectangles point downwards for points above the line, and vice versa.
run_tutorial("chapter3","ScPoEconometrics")
i cannot see the values in the "your guess" line on the left.
i have noticed that the newly organized apps are all tucked towards the upper bound of the browser window. differently from when we had tham in the .Rmd
files. must be some css setting. can you investigate how to have a border around the app?
06-MultipleReg.Rmd
this is similar to our existing app. the following list could be split into various apps.
add SSR, sum of errors (not squared), sum of absolute errors to simpe_reg. just print below.
some of this is relevant for both book and apps.
related to #6 : same app but also with a 3D plot of SSR(a,b).
try with code in inst/chapter4
.
pch
: use points?standard_errors_simple
appX \in {0,1}
, as in #18w = a + b * gender + c * height, gender \in {0,1}
set gender = 1
and a shifting regression line is what we want.this is related to 4.1.4 in https://scpoecon.github.io/ScPoEconometrics/linreg.html
the example illustrates that linear statistics are only infomrative about linear relationships. all 4 plots have the same statistics: mean, reg line, corr etc, but obviously this is not very informative if the data are very nonlinear. it would be great to have an app that uses this example. One could do
this is the code form the R help for anscombe
which makes the 4 plots.
##-- now some "magic" to do the 4 regressions in a loop:
ff <- y ~ x
mods <- setNames(as.list(1:4), paste0("lm", 1:4))
for(i in 1:4) {
ff[2:3] <- lapply(paste0(c("y","x"), i), as.name)
## or ff[[2]] <- as.name(paste0("y", i))
## ff[[3]] <- as.name(paste0("x", i))
mods[[i]] <- lmi <- lm(ff, data = anscombe)
}
op <- par(mfrow = c(2, 2), mar = 0.1+c(4,4,1,1), oma = c(0, 0, 2, 0))
for(i in 1:4) {
ff[2:3] <- lapply(paste0(c("y","x"), i), as.name)
plot(ff, data = anscombe, col = "red", pch = 21, bg = "orange", cex = 1.2,
xlim = c(3, 19), ylim = c(3, 13),main=paste("dataset",i))
abline(mods[[i]], col = "blue")
}
par(op)
see screenshot on current readme of the repo.
Recent issue #54 about bug in tutorials needs to be covered by tests.
learnr
tutorials and deploy each app as a standalone app.build this app: https://gallery.shinyapps.io/simple_regression/
this:
> aboutApp("regression")
Error: Please run `launchApp()` with a valid app as an argument.
Valid apps are: 'anscombe', 'confidence_intervals', 'corr_continuous', 'datasaurus', 'demeaned_reg', 'multicollinearity', 'reg_constrained', 'reg_dummy', 'reg_dummy_example', 'reg_full', 'reg_multivariate', 'reg_simple', 'reg_standardized', 'rescale', 'sampling', 'SSR_cone', 'standard_errors_changeN', 'standard_errors_simple'
needs to be changed to
# locate all the shiny app examples that exist
valid <- character(0)
v <- list.files(system.file("shinys", package = "ScPoEconometrics"),full.names=TRUE)
for (i in v){
# if i has an about.Rmd
if (file.exists(file.path(i,"about.Rmd"))){
valid <- c(valid,basename(i)
}}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.