Advertisement
phirippu

Untitled

May 4th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.66 KB | None | 0 0
  1. require(ggplot2)
  2. year=2013
  3. path="C:\\dir\\"
  4. df=read.csv(file = paste0(path, "SAM_global_",toString(year),".csv"))
  5. colnames(df)
  6. for (row in 2:nrow(df)){
  7.   p1 = df[row-1,"Pa"]
  8.   p2 = df[row,"Pa"]
  9.   df[row, "dPa"] = p1-p2
  10. }
  11.  
  12. library(MASS)
  13. fit <- lm(FCH4MF0~Ta+RH+Pa+Ts_7cm+Ustar+Rain+Ts_2cm+Ts_8cm,data=df)
  14.  
  15. step <- stepAIC(fit, direction="both")
  16. step$anova
  17. step$coefficients
  18. plot(fit)
  19.  
  20. require(olsrr)
  21. model <- lm(FCH4MF0~Ta+RH+dPa+Ts_7cm+Ustar+Rain+Ts_2cm+Ts_8cm,data=df)
  22. ols_step_both_aic(model, details = TRUE )
  23.  
  24. fm = formula(log(FCH4MF0)~Ta+RH+dPa+Ts_7cm+Ustar+Rain+Ts_2cm+Ts_8cm)
  25. model <- lm(fm,data=df)
  26. ols_step_both_aic(model, details = TRUE )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement