R Markdown

Questions

  1. Evaluate the following mathematical function using R

\[|x^{\frac{2}{3}}-\frac{5!-e^{2log_{10}(45 sin(5\pi/6)}}{\sqrt32}|\]

Answer

sinex<-45*sin(5*pi/6)
num_1<-5886^(2/3)
num_2<-factorial(5)
num_3<- exp(2*log(sinex,10))
q1_answer=abs(num_1-((num_2-num_3)/(sqrt(32))))
q1_answer
## [1] 307.4256
  1. The fibonacci sequence is the series of numbers: > 0,1,1,2,3,5,8,13,21,….
    Answer
func_1<- function(){
  a=0
  b=1
  c=a+b
  icount=4
  for (i in 0:995){
      a=b
      b=c
      c=a+b
    
    icount=icount+1
  
  }
cat(icount,"*")
 print(c)    
  
  
}
func_1()
## 1000 *[1] 1.660275e+208
  1. The following is a linear regression result:

Fill in (i)-(iv) in the ANOVA table above.

t_stat<-11.635
SE<-323.2
beta0_hat<-SE*t_stat
cat("i =", beta0_hat)
## i = 3760.432
t_stat<-4.798
beta1_hat<-873.5
SE<-beta1_hat/t_stat
cat("ii =", SE)
## ii = 182.055
beta2_hat<-351.6
SE<-239.7
t_stat<-beta2_hat/SE
cat("iii =", t_stat)
## iii = 1.466834
p_value = 2*pt(abs(-2.074), df=722, lower.tail=TRUE)
cat("iv =", p_value)
## iv = 1.961567

Interpret the parameter estimate of variable `temp’.**

Temp variable: temps on an hourly scale, bike rentals increase an average of 6,579.1

Interpret the parameter estimate of variable `holiday’.

Holiday’s: On a non-holiday, bike rentals decrease an average of 608.2

Find the predicted value (ŷ ) and the residual (r) when season=1, holiday=1, temp=0.35, hum= 0.8, windspeed=0.2, and cnt = 1000.

\[y=1.96 + 873.5(season2) + 351.6(season3) + 1439.1(season4) -608.2(holiday) + 6579.1(temp) -3746.9(hum) -4231.0(windspeed)\]

Answer

y_hat = 1.96+873.5*0 + 351.6*0 + 1439.1*0 -608.2*1 + 6579.1*0.35 -3746.9*0.8 -4231.0*0.2

cnt = 1000
residual= cnt-y_hat
cat("y_hat=", y_hat)
## y_hat= -2147.275
cat("residual=", residual)
## residual= 3147.275