Reputation: 1
I have some datas which looks like obeying gausssian distribution. So i use
my.glm<- glm(b1~a1,family=Gaussian)
and then use command
summary(my.glm)
.
The results are:
Call:
glm(formula = b1 ~ a1, family = gaussian)
Deviance Residuals:
Min 1Q Median 3Q Max
-0.067556 -0.029598 0.002121 0.030980 0.044499
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.433697 0.018629 23.28 1.36e-12 ***
a1 -0.027146 0.001927 -14.09 1.16e-09 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for gaussian family taken to be 0.001262014)
Null deviance: 0.268224 on 15 degrees of freedom
Residual deviance: 0.017668 on 14 degrees of freedom
AIC: -57.531
Number of Fisher Scoring iterations: 2
I think they fit well. But how can i draw a gaussian curve on these datas?
Upvotes: 0
Views: 1316
Reputation: 31761
Assuming that the intercept has a normal distribution, you can plot its distribution like this:
x <- seq(0.3,0.6,by =0.001)
plot(x, dnorm(x, 0.433697, 0.018629), type = 'l')
and you might want to add your data:
rug(b1)
since you didn't supply data, we can make some up (with some transforms to match stats in the example):
set.seed(0)
b <- rnorm(15)
b1 <- ((b - mean(b))/sd(b) * 0.018629) + 0.433697
rug(b1)
you could also overlay a kernel density estimate of the data
lines(density(b1), col = 'red')
Giving the following plot:
Upvotes: 1
Reputation: 21532
Simple: ?dnorm
Use dnorm to create a gaussian curve of desired mean and s.d. without tying yourself to any numerically fitted function. This is a simple, and good, way to show how your data 'fits' to a theoretical curve. Not the same thing as plotting the fitted data and trying to figure out "how close" to a gaussian it is.
Upvotes: 0