3.) Solution process:
library(ggplot2)
library(plotly)
library(manipulate)
B0=4
B1=.1
curve <-function(x) B0+B1*x^2
tangential <- function(x) (2*B1*10)*(x-10)+(B0+B1*10^2)
y=c(-30,30)
x=c(-30,30)
ggplotly(ggplot(data.frame(x=x,y=y),aes(y=y,x=x))+stat_function(fun=curve,color="#32E4DF")+stat_function(fun=tangential,color="#E44C32")+theme_minimal(base_family = "courier"))
\[\begin{equation} \label{eq1}
\begin{split}
\frac{\triangle y}{\triangle x} & =
2 \beta_1 x
\end{split}
\end{equation}\]
4.) Solution process:
GPA<-c(2.8,3.4,3.0,3.5,3.6,3.0,2.7,3.7)
ACT<-c(21,24,26,27,29,25,25,30)
sACT <- ACT^.5
mean(sACT)->msACT
mean(GPA)->mGPA
sum((sACT-msACT)*(GPA-mGPA))/sum((sACT-msACT)^2)->B1
B0=mGPA-B1*msACT
curve <- function(x) B0+B1*x^.5 # Nonlinear regression
curve1<-function(x) coef(lm(GPA~ACT))[1]+coef(lm(GPA~ACT))[2]*x # Compare with linear regression
ggplotly(ggplot(data.frame(x=ACT,y=GPA), aes(x=ACT,y=GPA))+geom_point(color="#CB32E4")+stat_function(fun=curve,color="#32E4DF")+stat_function(fun=curve1,color="#E44C32")+theme_minimal(base_family = "courier")) # Blue line is nonlinear and red line is linear
Now the prediction has made:
curve <- function(x){B0+B1*x^.5}
round(curve(25)-curve(20),digits=1)
## [1] 0.5
5.) Solution process:
curve <- function(x){2+0.03*x}
curve(10)-curve(0)
## [1] 0.3
8.) Solution process:
curve<-function(x){3+0.005*x+0.02*x}
percent <- function(P){paste(100*P,"%",sep="")}
percent(curve(10)-curve(0))
## [1] "25%"
9.) Solution process:
curve<-function(education,experience,tenure){exp(0.3+0.1*education+0.005*experience+0.02*tenure)
}
curve(16,20,10)
## [1] 9.025013