## Your code
i <- 1:1000
sum(1/i^2)
## [1] 1.643935
## replace NULL with your answer (by replacing NULL with the variable containing your answer)
\(F_n = F_{n-1} + F_{n-2}\). Given the seed value \(F_1 = 1\) and \(F_2 = 1\), what is \(F_{100}\)?
## Your code
N <- 100
F <- rep(NA, N)
F[1] <- 1
F[2] <- 1
for(n in 3:N){
F[n] <- F[n-1] + F[n-2]
}
F[N] ## replace NULL with your answer (by replacing NULL with the variable containing your answer)
## [1] 3.542248e+20
## Your code
plot(x=cars$speed, y = cars$dist, xlab="speed", ylab="dist", main="dist vs speed")
In R base package, there is mtcars’ data. data(mtcars)
## Your code
lmfit <- lm(mpg ~ cyl + disp + hp + drat, data=mtcars)
summary(lmfit)
##
## Call:
## lm(formula = mpg ~ cyl + disp + hp + drat, data = mtcars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.5660 -1.8161 -0.6469 1.4094 6.5749
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 23.98524 7.98905 3.002 0.00571 **
## cyl -0.81402 0.84368 -0.965 0.34318
## disp -0.01390 0.01089 -1.276 0.21287
## hp -0.02317 0.01576 -1.470 0.15299
## drat 2.15405 1.59866 1.347 0.18905
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.012 on 27 degrees of freedom
## Multiple R-squared: 0.7825, Adjusted R-squared: 0.7503
## F-statistic: 24.29 on 4 and 27 DF, p-value: 1.314e-08
## Your code
pvalue <- summary(lmfit)$coefficients["cyl", "Pr(>|t|)"]
print(pvalue) ## replace NULL with your answer (by replacing NULL with the variable containing your answer)
## [1] 0.3431833