Regression of a complex model in R [closed] - r

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
This is just a simplified version of what I have to do.
I have to perform a linear mixed effects regression for the following model:
y~a1+F1+F2+(1|Effect1)+(1|Effect2)
The problem I have is coding the fixed effects.
F1=a2*(M-M1)+a4*(10-M) if M >=M1
=a3*(M-M2)+a4*(10-M1) if M < M1
F2=a5*ln(R+a6)+a7*lnV if V<100
=a5*1.5+a7 if V>=100
M,R,V,y,M1 & M2 are given and so are the Effects1 & Effects2. Also it is a large data set.
I have to find the regression coefficients a1,a2,a3,a4,a5,a6,a7. Is there a way to do this in R?Like specifying the coefficients as variables or any other approach.
Edit: I have removed the F3 term and modified the F2 term, because it was causing a lot of confusion and I am mainly concerned about the first 2 terms

Related

What is the R code for Nested minimization to work out an estimate for c^((k)) in a non linear threshold regression model [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
Improve this question
〖〖rx〗(t+12)〗^((k))= α_1 + 〖α_2〗^((k) ) 1(zt≤c^((k) ))+〖β_1〗^((k)) 〖s_t〗^((k))+ 〖β_2〗^((k)) 〖s_t〗^((k)) 1(zt≤c^((k) ))+〖ε(t+12)〗^((k)), That is the regression model
I cant figure out exactly how to input the correct R code for this model using nested minimisation technique

Looking for resources for help modeling logistic regression with an event/trial syntax in R? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 days ago.
Improve this question
I am modeling bird nesting success and my advisor wants me to use event/trials syntax in R to model the amount of eggs that hatched vs the total amount of eggs per nest (i.e. the event/trials) against a variety of predictor variables - using essentially the logistic regression format.
This is totally new to me, so any online resources or code help would be incredibly useful! Thank you!
Haven't tried much yet, can't find the resources! I can only find info for SAS.
When specifying a logistic regression with glm(), the response can be specified multiple different ways. One is as a two-column matrix, first column is number of successes, second is number of failures.
So if you have two variables, total_eggs and hatched, try
mod <- glm( cbind(hatched, total_eggs-hatched) ~ x + ...,
data=your_data_frame, family=binomial)

How to Constrain the slope to be positive in regression? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How can I constrain my regression coefficient (only the slope, not the intercept) to be positive? It's a general statistical question, but specifically, I would like to have an r solution, and even more specifically when using model 2 regression (major axis regression).
You could do linear regression with nls, and limit the paramater range there.
Example: Using the nl2sol algorithm from the Port library we want to find a data set with x and y values with a negative Y-intercept and slope between 1.5 and 1.6:
nls(y~a+b*x,algorithm="port",start=c(a=0,b=1.5),lower=c(a=-Inf,b=1.4),upper=c(a=Inf,b=1.6))
This solution and others are explained in the more general question at https://stats.stackexchange.com/questions/61733/linear-regression-with-slope-constraint

logistic regression R prediction function [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a glm model and use the following script:
prob=predict(myglm,type=("response"))
If i export this prob vector i get 1 column with all the probabilities.
prob=predict(myglm,type=("terms"))
This will provide me the terms for each observation in my data set.
My question is how can I export the data set with the
response probability column added to the end of the file?
Thanks is advance!
Is all you want to add a column with the predicted probability to the dataframe used to build the model? If so you do it this way:
mydata$prob <- predict(myglm, type = "response")
Please read An Introduction to R to learn the basics of the R language, it is the standard tutorial.

modelling claim loss using tweedie distribution in R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i want to fit a tweedie compound Poisson Gamma to my loss data using ptweedie.series R command. I am getting problems how to start with my fitting in R. Thanks in advance.
Performing such a fit is illustrated here:
library(tweedie)
example("tweedie-package")

Resources