glm

Fit and compare multiple sigmoid curves in R

ぃ、小莉子 提交于 2019-12-14 00:27:51
问题 I would like to fit multiple curves at once, and compare them statistically, in terms of their 3 estimated parameters – asymptote, slope and x0. Here is an idealized image of the data to be modeled: Most searchable pages turn up methods to fit a single curve, as seen here: http://kyrcha.info/2012/07/08/tutorials-fitting-a-sigmoid-function-in-r/ and here http://rstudio-pubs-static.s3.amazonaws.com/7812_5327615eb0044cf29420b955ddaa6173.html In my case, I would like to test (statistically) the

Accessing fitted.values when using ddply

社会主义新天地 提交于 2019-12-13 18:03:53
问题 I am using ddply to execute glm on subsets of my data. I am having difficulty accessing the estimated Y values. I am able to get the model parameter estimates using the below code, but all the variations I've tried to get the fitted values have fallen short. The dependent and independent variables in the glm model are column vectors, as is the "Dmsa" variable used in the ddply operation. Define the model: Model <- function(df){coef(glm(Y~D+O+B+A+log(M), family=poisson(link="log"), data=df))}

The tuning parameter in “glm” vs “rf”

给你一囗甜甜゛ 提交于 2019-12-13 07:43:25
问题 I am trying to build a classification model using method = "glm" in train . When I use method = "rpart" it works fine but when I switch to method = "glm" then it gives me an error saying The tuning parameter grid should have columns parameter I tried using cpGrid = data.frame(.0001) also cpGrid = data.frame(expand.grid(.cp = seq(.0001, .09, .001))) But both throwing an error. Below is my initial code numFolds = trainControl(method = "cv", number = 10, repeats = 3) cpGrid = expand.grid(.cp =

Comparing two vectors (predicted/expected)

跟風遠走 提交于 2019-12-13 06:46:55
问题 I am trying to do something close to a shallow bootstrapping but I am struggling with data type. Here is the script : library(languageR) data(dative) sub1<-dative[grepl("S10|S11",dative$Speaker),] mod_sub1<-glm(RealizationOfRecipient~Verb+SemanticClass+LengthOfRecipient+AnimacyOfRec+DefinOfRec+PronomOfRec+LengthOfTheme+AnimacyOfTheme+DefinOfTheme+PronomOfTheme+AccessOfRec+AccessOfTheme,family='binomial',data=sub1) comp_sub1<-dative[!grepl("S10|S11",dative$Speaker),] expected_compsub1 <- comp

Checking interpretation of GLM summary in R

假如想象 提交于 2019-12-13 03:55:36
问题 Just want to check that what I'm doing is all correct! I have bird counts in several sites categorised into two habitats - farmland and wetland. I simply want to see which habitat has higher counts. I'm using a GLM with a Poisson function (as they are count data): > mod <- glm(count ~ habitat, family = "poisson") > summary(mod) Call: glm(formula = count ~ habitat, family = poisson) Deviance Residuals: Min 1Q Median 3Q Max -0.5868 -0.4603 -0.2496 -0.2141 2.8464 Coefficients: Estimate Std.

`Summary` multiple LM and GLM objects

一世执手 提交于 2019-12-13 03:52:16
问题 I have 50 lm and glm objects in R. I want to get the summary of all of them without having to type summary(lm...) 50 times. Is there a quick way to do it? The names of the dataset begin the same way: lin.mod.t# or lin.mod.s# where {# = 1,2,...,25}. I can list all the models using ls(pattern = "lin.mod") objects(pattern = "lin.mod") But I cannot run summary for the outcomes of using ls or objects . I used summary(eval(parse(text = ls(pattern = "lin.mod")))) , but this only runs the first one.

Fitting Multiple Logistic Regression with Interaction between Quantitative and Qualitative Explanatory Variables with drm function from drc package

六眼飞鱼酱① 提交于 2019-12-13 02:35:59
问题 As a follow up to this question answered by @EDi. I wonder how to fit the following glm model with drc function from drc package. GLM Code Type <- rep(x=LETTERS[1:3], each=5, times=2) Conc <- rep(rep(x=seq(from=0, to=40, by=10), times=3), 2) Rep <- factor(rep(x=1:2, each=15)) Total <- 50 Kill <- c( 10, 30, 40, 45, 38, 5, 25, 35, 40, 32, 0, 32, 38, 47, 40, 11, 33, 38, 43, 36, 4, 23, 34, 42, 34, 2, 35, 39, 46, 42 ) df <- data.frame(Type, Conc, Rep, Total, Kill) fm1 <- glm( formula = Kill/Total

Generalized Linear Regression Model With Binary Exposure and Interaction Terms

孤者浪人 提交于 2019-12-13 02:21:41
问题 I am running some fairly simple odds ratio analysis to investigate relationships of certain variable on injury outcomes. The exposure term (inj) is binary with 0 representing no injury and 1 meaning an injury is present. The interaction terms I am investigating are whether the person injured at work ( causeWork ; 0 represents not a work related injury and 1 represents a work injury) and the mechanism of injury ( mechanism ; multivariable ie. mechanismFall , mechanismObject , mechanismPerson )

Statsmodels Poisson glm different than R

北战南征 提交于 2019-12-12 15:07:02
问题 I am trying to fit some models (Spatial interaction models) according to some code which is provided in R. I have been able to get some of the code to work using statsmodels in a python framework but some of them do not match at all. I believe that the code I have for R and Python should give identical results. Does anyone see any differences? Or is there some fundamental differences which might be throwing things off? The R code is the original code which matches the numbers given in a

Custom Link function works for GLM but not mgcv GAM

老子叫甜甜 提交于 2019-12-12 13:15:49
问题 Apologies if the answer is obvious but I've spent quite some time trying to use a custom link function in mgcv.gam In short, I want to use a modified probit link from package psyphy ( I want to use psyphy.probit_2asym, I call it custom_link ) I can create a {stats}family object with this link and use it in the 'family' argument of glm. m <- glm(y~x, family=binomial(link=custom_link), ... ) It does not work when used as an argument for {mgcv}gam m <- gam(y~s(x), family=binomial(link=custom