Last active
August 19, 2021 11:19
-
-
Save SirmaXX/d1ba8a44d01f92fcb5b96f5f5afadf2c to your computer and use it in GitHub Desktop.
ödev6 nın kodları
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #gerekli kütüphaneler | |
| library(skedastic) | |
| library(lmtest) | |
| library(SciViews) | |
| library(MASS) | |
| #rastgelelik için gerekli sınır | |
| set.seed(1000) | |
| #veriseti ve modelin hazırlanması | |
| N <-100 | |
| X<-rgamma(N,shape=10) | |
| sigma2 = N^4 | |
| errors <-rnorm(N, mean=10,sd=ln(sigma2)) | |
| Ydata <- -9+0.914*X+errors | |
| Xdata <-X | |
| datatable <-data.frame(Ydata,Xdata) | |
| lastmodel <-lm(Ydata~Xdata,data = datatable ) | |
| rezz <- resid(lastmodel) | |
| qqplot(rezz) | |
| #kaydırılmış veriler | |
| newY<-Ydata+(4*mean(Ydata)) | |
| newX<-Xdata+(4*mean(Xdata)) | |
| bc <- boxcox(newY ~newX) | |
| #kaydırılmış verilerin modeli | |
| newregModel<-lm(newY~newX) | |
| newregModel | |
| #en uygun lambda değerinin bulunması | |
| (lambda <- bc$x[which.max(bc$y)]) | |
| new_model <- lm(((y^lambda-1)/lambda) ~ x) | |
| #yeni modelin artıklarının grafiği | |
| qqnorm(new_model$residuals) | |
| qqline(new_model$residuals) | |
| #eski modelin artıklarının grafiği | |
| qqline(lastmodel$residuals) | |
| qqnorm(lastmodel$residuals) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment