Regression Modells
Verfasst: So Mär 31, 2019 2:34 pm
Dear Community,
I have a Problem with one of my stan models I am using to do a linear Regression.
I have a dataset containign values for mathscores and readingscores with values ranging from 0 to 100.
Now I have two models and want to check which fits the data better. Either a model with a straight line or a model with a curved line.
Unfortunately, when I try to fit These models, I get a Syntax error saying: Arguments to ^ must be primitive (real or int)
I do not know what to do. Could you give me a hint here?
Thanks in Advance.
Here are my models:
```{r}
straight_line_string <- "
data {
vector [1000] readingscore;
vector [1000] mathscore;
}
parameters {
real alpha;
real beta;
real <lower=0> sigma;
}
model {
mathscore ~ normal(alpha + beta * readingscore, sigma);
}
"
curved_line_string <- "
data {
vector [1000] readingscore;
vector [1000] mathscore;
}
parameters {
real alpha;
real beta;
real <lower=0, upper=1.5> d;
real <lower=0> sigma;
}
model {
d ~ normal(1.5,0);
mathscore ~ normal(readingscore ^ (d) * beta + alpha, sigma);
}
"
I have a Problem with one of my stan models I am using to do a linear Regression.
I have a dataset containign values for mathscores and readingscores with values ranging from 0 to 100.
Now I have two models and want to check which fits the data better. Either a model with a straight line or a model with a curved line.
Unfortunately, when I try to fit These models, I get a Syntax error saying: Arguments to ^ must be primitive (real or int)
I do not know what to do. Could you give me a hint here?
Thanks in Advance.
Here are my models:
```{r}
straight_line_string <- "
data {
vector [1000] readingscore;
vector [1000] mathscore;
}
parameters {
real alpha;
real beta;
real <lower=0> sigma;
}
model {
mathscore ~ normal(alpha + beta * readingscore, sigma);
}
"
curved_line_string <- "
data {
vector [1000] readingscore;
vector [1000] mathscore;
}
parameters {
real alpha;
real beta;
real <lower=0, upper=1.5> d;
real <lower=0> sigma;
}
model {
d ~ normal(1.5,0);
mathscore ~ normal(readingscore ^ (d) * beta + alpha, sigma);
}
"