## Regression Modells

Modelle zur Korrelations- und Regressionsanalyse

Moderator: EDi

desperatestanuser
Beiträge: 1
Registriert: So Mär 31, 2019 1:06 pm

### Regression Modells

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?
Here are my models:

```{r}
straight_line_string <- "
data {
vector  mathscore;
}
parameters {
real alpha;
real beta;
real <lower=0> sigma;
}
model {
mathscore ~ normal(alpha + beta * readingscore, sigma);
}
"
curved_line_string <- "
data {
vector  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);
}
"

bigben
Beiträge: 988
Registriert: Mi Okt 12, 2016 9:09 am

### Re: Regression Modells

Hi there,

I am not much of a stan user, I don't think I have a running stan at hand, but I see two things I do not understand.

d is to be taken from normal(1.5, 0) - but what sense does that make with sigma = 0 ?

Also, what do the parenthesis in "readingscore ^ (d) * beta + alpha" mean?

Finally ands most important, I would try to use the "pow" function of "^".

JMTC,
Bernhard
---
Programmiere stets so, dass die Maxime Deines Programmierstils Grundlage allgemeiner Gesetzgebung sein könnte