Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Ludy Thenor Research Methods I- Final Part 2
#Ludy Thenor #John Jay College of Criminal Justice #Research Methods I- Final y<-c( 11.06, 11.07, 10.83, 10.60, 10.58, 10.75, 10.62, 10.69, 10.80, 10.85, 10.79, 10.77, 10.76, 10.74, 10.73, 10.78, 10.81, 10.93, 10.99, 11.16, 11.49, 11.57, 11.90, 12.00, 12.03, 12.14, 12.28, 12.47, 12.25, 12.38, 12.22, 12.06, 11.99, 11.98, 11.92, 11.82, 11.74, 11.91, 12.04, 12.08, 11.97, 11.97, 11.95, 11.96, 11.94, 11.78, 11.68, 11.54, 11.27, 11.12, 11.03, 10.78, 10.97, 10.78, 10.84, 10.74, 10.93, 10.93, 11.03, 11.15, 11.37, 11.61, 11.75, 11.83, 11.90, 12.03, 12.09, 12.17, 12.17, 12.21, 12.25, 12.22, 12.16, 12.14, 12.18, 12.23, 12.30, 12.43, 12.58, 12.64, 12.56, 12.67, 12.81, 12.99, 13.13, 13.28, 13.13, 13.58, 13.31, 13.26, 13.28, 13.29, 13.29, 13.30) x2 <-c( 136.7, 140.7, 146.4, 150.0, 152.3, 155.5, 158.1, 159.7, 160.4, 160.7, 161.1, 163.9, 164.2, 164.6, 170.4, 177.7, 180.2, 182.9, 186.9, 187.9, 189.9, 190.9, 192.1, 194.5, 192.8, 190.0, 189.4, 189.8, 188.2, 187.0, 186.1, 184.1, 184.3, 184.1, 184.3, 186.3, 183.8, 182.1, 181.1, 180.3, 181.1, 181.9, 181.8, 181.3, 182.9, 184.3, 186.3, 188.9, 187.4, 187.8, 190.9, 193.0, 194.6, 196.6, 197.8, 198.9, 200.6, 203.3, 205.7, 208.6, 209.0, 210.8, 215.6, 220.0, 223.7, 227.2, 229.2, 229.8, 232.1, 235.3, 238.7, 241.6, 244.2, 247.0, 251.3, 257.4, 261.4, 265.5, 268.9, 271.1, 276.7, 279.1, 279.8, 283.8, 285.8, 288.1, 292.2, 293.4, 289.6, 288.4, 288.7, 291.4, 296.8, 302.6, 309.8, 316.2, 316.2, 315.3, 317.2, 321.3, 325.9, 329.6, 332.4, 336.0, 339.5, 343.2, 347.2, 356.0, 360.5) x1<-c( 4958.9, 4857.8, 4850.3, 4936.6, 5032.5, 4997.3, 5056.8, 4997.1, 4914.3, 4935.5, 4912.1, 4915.6, 4972.4, 5089.8, 5180.4, 5286.8, 5402.3, 5493.8, 5541.3, 5583.1, 5629.7, 5673.8, 5758.6, 5806.0, 5858.9, 5883.3, 5937.9, 5969.5, 6013.3, 6077.2, 6128.1, 6234.4, 6275.9, 6349.8, 6382.3, 6465.2, 6543.8, 6579.4, 6610.6, 6633.5, 6716.3, 6731.7, 6719.4, 6664.2, 6631.4, 6668.5, 6684.9, 6720.9, 6783.3, 6846.8, 6899.7, 6990.6, 6988.7, 7031.2, 7062.0, 7168.7, 7229.4, 7330.2, 7370.2, 7461.1, 7488.7, 7503.3, 7561.4, 7621.9, 7676.4, 7802.9, 7841.9, 7931.3, 8016.4, 8131.9, 8216.6, 8272.9, 8396.3, 8442.9, 8528.5, 8667.9, 8733.2, 8775.5, 8886.9, 9040.1, 9097.4, 9205.7, 9218.7, 9243.8, 9229.9, 9193.1, 9186.4, 9248.8, 9363.2, 9392.4, 9485.6, 9518.2, 9552.0, 9629.4) # Multivariate linear regression # y = b0 + b1*x (+ e) # will build method of moments model (sample-based estimates of y-int and coefficient of x) # y = bhat0 + bhat1(x) (+uhat) # Assumption 1 : E(e)=0 # Assumption 2 : cov(x,uhat)=0 # x1 : % African American pop by county in FL, 2000, US Census Bureau # x2 : Commercial and industrial loans (billions of dollars, not seasonally adjusted) # Citations # Source for x1 and x2: US Census Bureau, 2000 FL County-level data # Source for x2 and y: n <- length(x1) bhat1 <- (cov(x1,y)/var(x1)) # estimated x1-coefficient (slope) cor(RETS, use="pairwise.complete.obs") bhat0 <- (mean(y) - bhat1 * mean(x1)) # estimated y-intercept yhat <- (bhat0 + bhat1 *(x1)) # predicted y value uhat <- (y - yhat) # residual ess <- sum((yhat - mean(y))^2) # expected sum of squares rss <- sum((y - yhat)^2) # residual sum of squares tss <- sum((y - mean(y))^2) # total sum of squares r2 <- (ess/tss) # correlation coefficient ser <- (sqrt(rss / (n-2))) # standard error fstat <- (ess / (rss / (n-2))) # F-statistic n bhat1 bhat0 ess rss tss r2 ser fstat 1-pf(fstat, df1=1, df2=n-2) qf5 <- qf(.95, df1=1, df2=n-2) qf5 plot(x1,y) lines(x1, (bhat0+bhat1*x1), col="red") lm(formula = y ~ x1 ) summary(lm(formula = y ~ x1)) x2, drop.unused.levels = TRUE reg <- lm(y ~ x1) summary(reg) #Question 22 # An F test tests the following: H0: b0 = b1 = b2 = 0
run
|
edit
|
history
|
help
0
R multiplication
Dbinom
Good Ozone
10-08-2020Exe
Otavio-fez
Chev-nodes
BoxPlot_Anomaly
Hiring Discrimination
Demonstration of table()
Desktop-Sprite-image-Interval