BookmarkSubscribeRSS Feed
Abimal_Zippi
Fluorite | Level 6

Can you help how to write the design matrix to a SAS data set using proc transreg to obtain a basis spline function and also how to specify an interaction between spline(x) and a variable?

 

14 REPLIES 14
Rick_SAS
SAS Super FREQ

If you are willing to use PROC GLMSELECT instead of TRANSREG, see 

https://blogs.sas.com/content/iml/2020/06/08/interactions-spline-regression.html

 

Abimal_Zippi
Fluorite | Level 6
Thanks Rick, I have seen the blog and it is very helpful. Also, have seen your other blog on "visualize a regression with spline". First, I would like to output the design matrix to sas dataset using spline function (aim is to get the weighting function - not the spline effects) and then run the interaction with spline(x). I found the effect statement not helpful to do this. Can you suggest codes how to do it using proc GLMSELECT/TRASNREG?
Rick_SAS
SAS Super FREQ

I don't know what "get the weighting function" means. If you post some example data and state what you are hoping to get, that would be helpful.

Abimal_Zippi
Fluorite | Level 6
Thanks again, Rick. The aim is to model the cumulative effects of a time-varying exposure as the weighted sum of past doses (e.g. past 5 years exposures)- a weighted cumulative exposure. In this method, weights, will be modeled with cubic regression B-splines. I.e., the spline basis functions will represent the weighting function.
Rick_SAS
SAS Super FREQ

You still haven't posted data. From what you've said, it sounds like you want to run a two-step process. First, model the weights and score that model at the time points in your data. Then, run the regression and use the WEIGHT statement to use the weights from the first step.

Abimal_Zippi
Fluorite | Level 6

Happy New Year Rick, find below sample data - for each ID, the exposure time points and dose in the last 5 years -

data have;
input ID exposure_time_yr dose $;
cards;
1   0.1  15 
1   0.4  7.5
1   1.9  10
1   2    100
1   3.1  100
1   3.8  10
1   3.9  140
1   4.1  140
1   4.8  50
2   0.1 75
2   0.5  150
2   0.2  75
2   0.2  50
2   0.3 75
2   0.3 150
2   0.4  25
2   0.5  225
2   1    25
2   3.5  200
2   4.5  200
3   0.4  5
3   1.5  20
3   2.1  25
3   3    200
3   4.9  100

;
Rick_SAS
SAS Super FREQ

1. Why is dose a character variable? I'll assume that is a mistake.

2. How are you using the ID variable in the model?

3. Where is the weighting variable?

 

I still don't know what you are trying to accomplish. Can you sketch what you want? Are we supposed to be fitting some line or curves to the following scatter plot?

proc sgplot data=have;
 scatter y=exposure_time_yr x=dose / group=ID markerattrs=(symbol=CircleFilled size=12);
run;
Abimal_Zippi
Fluorite | Level 6

Yes, the dose is not a character!

As mentioned in  the previous threads,  I wanted the weighted sum of pas does over a 5-year window - the data shows the dose exposure and time points over 5 year for each ID. Weights, will be modeled with cubic regression B-splines. I.e., the spline basis functions will represent the weighting function.

Abimal_Zippi
Fluorite | Level 6

* the weighted sum of past doses over a 5-year window

Rick_SAS
SAS Super FREQ

Sorry, but I do not understand. Do you have a reference (textbook? journal article?) that provides details?

 

I am giving up. Perhaps someone else will be able to help you. Good luck.

WarrenKuhfeld
Ammonite | Level 13

Define what you mean by "weights." Look at examples of the WEIGHT statement in regression procs. Is that what you mean? Or do you mean regression coefficients? The TRANSREG documentation has examples of scoring as do many other procedures.

Abimal_Zippi
Fluorite | Level 6

In the paper mentioned above, " the weight function assigns the differential importance weights to past doses, depending on the time elapsed since the dose was taken" - weighted according to their relative proximity in time. 

Abimal_Zippi
Fluorite | Level 6

Thanks Rick, here is the link for the paper that I am referring to :

Modeling of cumulative effects of time-varying drug exposures on within-subject changes in a continu...

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 14 replies
  • 1724 views
  • 0 likes
  • 3 in conversation