Saeed Ahmadi
2009-Feb-24 10:46 UTC
[R] Syntax in taking log to transfrom the data to fit Gaussian distribution
Hi, I have a data set (weight) that does not follow the Gaussian (Normal) distribution. However, I have to transform the data before applying the Gaussian distribution. I used this syntax and used log(weight) as: posJy.model<-glm(log(weight) ~ factor(pos), family=gaussian(link='identity'), subset=Soil=="Jy"). This syntax COULD NOT transform the data. But if I transform the data before applying the model, then it works. The syntax is: weight<-log(weight) posJy.model<-glm(weight ~ factor(pos), family=gaussian(link='identity'), subset=Soil=="Jy") What is wrong with the first syntax. I have seen many scripts that the R users have applied any function (log, -, ...) directly inside the formulation. It will help me to understand the grammar of R. Thank you. Saeed -- View this message in context: http://www.nabble.com/Syntax-in-taking-log-to-transfrom-the-data-to-fit-Gaussian-distribution-tp22179656p22179656.html Sent from the R help mailing list archive at Nabble.com.
Petr PIKAL
2009-Feb-24 10:59 UTC
[R] Odp: Syntax in taking log to transfrom the data to fit Gaussian distribution
Petr Pikal petr.pikal at precheza.cz 724008364, 581252140, 581252257 r-help-bounces at r-project.org napsal dne 24.02.2009 11:46:07:> > Hi, > > I have a data set (weight) that does not follow the Gaussian (Normal) > distribution. However, I have to transform the data before applying the > Gaussian distribution. I used this syntax and used log(weight) as: > posJy.model<-glm(log(weight) ~ factor(pos), > family=gaussian(link='identity'), subset=Soil=="Jy"). This syntax COULDNOT> transform the data. But if I transform the data before applying themodel, Without going too much into details, there is nothing wrong in log inside formula try summary(glm(lot1 ~ log(u), data=clotting, family=Gamma)) summary(glm(log(lot1) ~ log(u), data=clotting, family=Gamma))> then it works. The syntax is: > > weight<-log(weight) > posJy.model<-glm(weight ~ factor(pos), family=gaussian(link='identity'), > subset=Soil=="Jy") > > > What is wrong with the first syntax.AFAIK, nothing Regards Petr I have seen many scripts that the R> users have applied any function (log, -, ...) directly inside the > formulation. > > It will help me to understand the grammar of R. > > Thank you. > Saeed > > > > > -- > View this message in context:http://www.nabble.com/Syntax-in-taking-log-to-> transfrom-the-data-to-fit-Gaussian-distribution-tp22179656p22179656.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Philipp Pagel
2009-Feb-24 11:08 UTC
[R] Syntax in taking log to transfrom the data to fit Gaussian distribution
On Tue, Feb 24, 2009 at 02:46:07AM -0800, Saeed Ahmadi wrote:> I have a data set (weight) that does not follow the Gaussian (Normal) > distribution. However, I have to transform the data before applying the > Gaussian distribution. I used this syntax and used log(weight) as: > posJy.model<-glm(log(weight) ~ factor(pos), > family=gaussian(link='identity'), subset=Soil=="Jy"). This syntax COULD NOT > transform the data. But if I transform the data before applying the model, > then it works. The syntax is: > > weight<-log(weight) > posJy.model<-glm(weight ~ factor(pos), family=gaussian(link='identity'), > subset=Soil=="Jy")That should work. Maybe you should tell us what happened or why you think it didn't work. Error messages? Unexpected results? cu Philipp -- Dr. Philipp Pagel Lehrstuhl f?r Genomorientierte Bioinformatik Technische Universit?t M?nchen Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://mips.gsf.de/staff/pagel