BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SBS
Obsidian | Level 7 SBS
Obsidian | Level 7

Could anyone help me on how to include offset parameter in NLMIXED model with negative binomial? Is the below inclusion of log_TotalWordsInSentence  (log of number of words in a sentence) variable correct?

 

proc nlmixed data=myData;
xb = b0 + b1a*(Gender = 'female') + u;
mu = exp(xb + log_TotalWordsInSentence);
m = 1/alpha;
ll = lgamma(CountPronounsInSentence+m)-lgamma(CountPronounsInSentence+1)-lgamma(m)
+ CountPronounsInSentence*log(alpha*mu)-(CountPronounsInSentence+m)*log(1+alpha*mu);
model CountPronounsInSentence ~ general(ll);
random u ~ normal(0,s2u) subject=person_id;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
pau13rown
Lapis Lazuli | Level 10

sorry, i dont visit the message boards as frequently as i'd like to.... The code looks ok to me. Personally for clarity i might write it as:

 

bounds b2<=1, b2>=1;

xb = b0 + b1a*(Gender = 'female') + b2*log_TotalWordsInSentence + u;
mu = exp(xb);

 

and a minor thing: I'd reduce the length of the variable name 'CountPronounsInSentence' to make it readable, i didn't bother to read the loglikelihood equation ("ll = ")... because it's hard to read

View solution in original post

4 REPLIES 4
Rick_SAS
SAS Super FREQ

@pau13rown is probably a better person to answer this, but your formula looks okay to me. Alternatively, instead of 

mu = exp(xb + log_TotalWordsInSentence);

you could use

mu = TotalWordsInSentence*(exp(xb));

which is equivalent (take log of both sides, bring  log_TotalWordsInSentence to the left, combine logs, then exponentiate.)

SBS
Obsidian | Level 7 SBS
Obsidian | Level 7
Thanks a lot Rick. I hope Paul Brown responds.
pau13rown
Lapis Lazuli | Level 10

sorry, i dont visit the message boards as frequently as i'd like to.... The code looks ok to me. Personally for clarity i might write it as:

 

bounds b2<=1, b2>=1;

xb = b0 + b1a*(Gender = 'female') + b2*log_TotalWordsInSentence + u;
mu = exp(xb);

 

and a minor thing: I'd reduce the length of the variable name 'CountPronounsInSentence' to make it readable, i didn't bother to read the loglikelihood equation ("ll = ")... because it's hard to read

SBS
Obsidian | Level 7 SBS
Obsidian | Level 7
Thanks a to Paul!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 4 replies
  • 2395 views
  • 2 likes
  • 3 in conversation