I used gam to simulate and then predict Y by X, Z, and Xt variables, but I am not sure about how to use these variables in gam. I appreciate it if you could help me about it.
X and Z are numbers and I assume there is an interaction between them.
Xt is treatment as factor (with 2 levels, 1 = low and 2 = high).
Xt has a direct effect on X variable. The increase in Xt should decreases the X value.
I used the gam function as follow:
gm1 = gam(Y ~ s(X) + s(X, by = Xt) + ti(X, Z), data = Input_data , family = Gamma(link ="log") , method="REML" ,na.action = na.exclude)
Predict_data$Y1 = predict(gm1, exclude = ‘s(X, by = Xt)’, new_data , type = "response")
If I want to find the effects of treatment Xt on X and then Y variable which form of these smooth functions are correct?
s(X, by = Xt)
s(X) + s(X, by = Xt)
s(X , Xt, bs = 'tp' )
s(X , Xt, bs = c( 'tp', ‘re’) )
Is it right if I just use s(X) to measure the effects of Xt and X on Y? because the effect of Xt treatment on Y is already reflected on X variable.
Can I use the predict function by excluding ‘s(X, by = Xt)’ for a new dataset without Xt variable? (the new dataset contains dummy data of all variables except Xt)
Dear Gavin,
I used gam to simulate and then predict Y by X, Z, and Xt variables, but I am not sure about how to use these variables in gam. I appreciate it if you could help me about it. X and Z are numbers and I assume there is an interaction between them. Xt is treatment as factor (with 2 levels, 1 = low and 2 = high). Xt has a direct effect on X variable. The increase in Xt should decreases the X value. I used the gam function as follow: gm1 = gam(Y ~ s(X) + s(X, by = Xt) + ti(X, Z), data = Input_data , family = Gamma(link ="log") , method="REML" ,na.action = na.exclude)
Predict_data$Y1 = predict(gm1, exclude = ‘s(X, by = Xt)’, new_data , type = "response")
If I want to find the effects of treatment Xt on X and then Y variable which form of these smooth functions are correct? s(X, by = Xt) s(X) + s(X, by = Xt) s(X , Xt, bs = 'tp' ) s(X , Xt, bs = c( 'tp', ‘re’) )
Is it right if I just use s(X) to measure the effects of Xt and X on Y? because the effect of Xt treatment on Y is already reflected on X variable.
Can I use the predict function by excluding ‘s(X, by = Xt)’ for a new dataset without Xt variable? (the new dataset contains dummy data of all variables except Xt)
Thank you Nat