Created
February 16, 2015 08:20
-
-
Save romunov/ff8688434c753b83d849 to your computer and use it in GitHub Desktop.
morfoliza
This file contains 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
```R | |
--- | |
title: "Analiza - CRO" | |
author: "Teo" | |
date: "Sunday, February 15, 2015" | |
output: html_document | |
--- | |
```{r} | |
library(ggplot2) | |
library(nlme) | |
library(sp) | |
library(dplyr) | |
``` | |
```{r} | |
cro <- read.table("morfo.txt", header = TRUE, sep = "\t") | |
str(cro) | |
cro <- na.omit(cro) | |
cro$GKY <- cro$GKY + rnorm(nrow(cro)) | |
cro$GKX <- cro$GKX + rnorm(nrow(cro)) | |
levels(cro$locality) <- c("Izvor Spilja Ricina", "Severova spilja", "Luska spilja", | |
"Pecina spilja", "Ponor Susik", "Rudnica VI", "Sinicic spilja", | |
"Vidovica spilja", "Vranovski ponor", "Zagorska pec") | |
``` | |
## Model 1 | |
```{r} | |
lm.G1bl <- lm(S.G1 ~ toto, data = cro) | |
summary(lm.G1bl) | |
ggplot(cro, aes(x=toto, y=S.G1)) + | |
theme_bw() + | |
geom_point() + | |
geom_smooth(method= lm) | |
confint(lm.G1bl, level = 0.95) | |
anova(lm.G1bl) | |
``` | |
## Model 2 | |
```{r} | |
lm.G2bl <- lm(S.G2~ toto, data = cro) | |
summary(lm.G2bl) | |
ggplot(cro, aes(x = toto, y = S.G2)) + | |
theme_bw() + | |
geom_point() + | |
geom_smooth(method = lm) | |
confint(lm.G2bl, level = 0.95) | |
anova(lm.G2bl) | |
``` | |
## Prostorska avtokorelacija | |
```{r} | |
mdl.pac <- gls(resP7 ~ community * flow, data = cro) | |
mdl.tmp <- gls(resP7 ~ community + flow, data = cro) | |
AIC(mdl.pac, mdl.tmp) | |
plot(mdl.pac) | |
mario.vario <- Variogram(mdl.pac, form =~ Xnew + GKY, robust = TRUE, maxDist = 80000, resType = "response") | |
plot(mario.vario) | |
# xy <- cro | |
# coordinates(xy) <- ~ Xnew + GKY | |
# plot(xy, col = xy@data$community) | |
coordinates(cro) <- ~ GKX + GKY | |
gls.spher <- gls(resP7 ~ community * flow, correlation = corSpher(form = ~ GKX + GKY, nugget = TRUE), method = "REML", data = cro) | |
# gls.lin <- gls(resP7 ~ community * flow, correlation = corLin(form = ~ GKX + GKY, nugget = TRUE), method = "REML",data = cro) | |
gls.ratio <- gls(resP7 ~ community * flow, correlation = corRatio(form = ~ GKX + GKY, nugget = TRUE), method = "REML", data = cro) | |
gls.gaus <- gls(resP7 ~ community * flow, correlation = corGaus(form = ~ GKX + GKY, nugget=TRUE), method = "REML",data = cro) | |
gls.exp <- gls(resP7 ~ community * flow, correlation = corExp(form = ~ GKX + GKY, nugget=TRUE), method = "REML", data = cro) | |
# AIC(mdl.pac, gls.spher, gls.lin, gls.ratio, gls.gaus, gls.exp) | |
AIC(mdl.pac, gls.spher, gls.ratio, gls.gaus, gls.exp) # gls.lin ne konvergira (rad) | |
``` | |
vse isto sranje. Izgleda, da ni avtokorelacije. | |
## Mešani modeli | |
```{r} | |
ggplot(as.data.frame(cro), aes(x = community, y = resP7, color = flow)) + | |
theme_bw() + | |
geom_point(size = 3) + | |
facet_wrap(~ locality) | |
mdl.lme1 <- lme(resP7 ~ community * flow,random= ~1|locality, method="REML",data = cro) | |
mdl.noflow <- lme(resP7 ~ community, random = ~ 1|locality, method = "REML", data = cro) | |
summary(mdl.lme1) | |
as.data.frame(cro) %>% | |
group_by(flow) %>% | |
summarize(mean(resP7)) | |
``` | |
Primerjamo AIC "polnega" modela in modela brez `flow`. | |
```{r} | |
AIC(mdl.lme1, mdl.noflow) | |
``` | |
Model brez `flow` se poslabša. Podpora tezi, da `flow` vpliva na dolžino P7. | |
## Brez Rudnice | |
```{r} | |
nirudnice <- cro[!cro$locality %in% "Rudnica VI", ] | |
``` | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment