I have a dataset defined by 2 variables
> head(as.data.frame(d))
age asthma
1 54.0 1
2 57.0 1
3 42.0 2
4 44.0 1
5 56.6 1
6 58.0 1
> summary(d$asthma)
1 2 NA's
6937 1105 876
>
I would like to estimate the density distribution of asthma as a function of age. So something like P(asthma==1|age=23) = p
.
During this estimation I need to take into account that this estimated probability should be a continous function of the age.
In other words P(asthma==1|age=45) ~ P(asthma==1|age=46)
I would like to know what is the method that I should use and how to compute it in R with my dataframe.
Ideally I would in the end to generate a plot of the obtained distribution P(asthma==1|age=x)