Actuarial Outpost
 
Go Back   Actuarial Outpost > Exams - Please Limit Discussion to Exam-Related Topics > SoA/CAS Preliminary Exams > Exam PA: Predictive Analytics
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions

Browse Open Actuarial Jobs

Life  Health  Casualty  Pension  Entry Level  All Jobs  Salaries


Reply
 
Thread Tools Search this Thread Display Modes
  #271  
Old Yesterday, 01:42 AM
samdman82 samdman82 is offline
Member
 
Join Date: Jul 2007
Posts: 244
Default

A few questions on the Actex Sample Exam, task 8

1) How come VehicleType was not binarized along with the other factor variables?
2) When binarizing, when do I use Fullrank = TRUE, and when do i use Fullrank = FALSE and manually Null out the base variable?
3) in the Interpretation explanation, how come we are comparing each level of VAgeCat (4, 5, 6) to the levels of "Age Groups 0-3". Shouldn't it just be the base Age Group 0?

thanks in advance.
Reply With Quote
  #272  
Old Yesterday, 02:16 AM
windows7forever windows7forever is offline
Member
SOA
 
Join Date: Apr 2016
Posts: 490
Default

I practiced June 2019 PA exam with shorter response again and have not seen a lot comments from your exam solution analysis regarding how to interpret stepAIC() output within each stepwise selected model regardless of AIC or BIC criteria used below. I want to confirm with you if my understanding summarized from what I saw in model output is correct below:

For forward selection method, we start with the null model and add one predictor at a time to the model.

If the resulting AIC/BIC increases or does not change next to "+predictor_name" compare to baseline with symbol "-", then we should not consider keeping the predictor since there's no model improvement by adding the predictor. "Traffic Control" is an example in that exam with no change in AIC/BIC after being added to the model.

If the resulting AIC/BIC decreases, then we should consider keeping the predictor since there's some model improvement for keeping the predictor.

For backward selection method, we start with the full model and drop one predictor at a time from the model.

If the resulting AIC/BIC increases or does not change next to "- predictor_name" compare to baseline with symbol "-", then we should not consider dropping the predictor since there's no model improvement by dropping the predictor.

If the resulting AIC/BIC decreases, then we should consider dropping the predictor since there's some model improvement without the predictor.

Thanks.

Last edited by windows7forever; Yesterday at 02:22 AM..
Reply With Quote
  #273  
Old Yesterday, 01:20 PM
Gmrgms Gmrgms is offline
SOA
 
Join Date: Jan 2020
College: Valparaiso University
Posts: 5
Default

Quote:
Originally Posted by Sader View Post
How would you treat the offset_var if the glm is gaussian with identity link but you took the log of the target variable? Which code chunk is correct? Would we ever take the log of the offset_var at the top portion of the logic
"- log(offset_var)"?
Or only in the portion of the logic that says
"offset = "
when we have a log link?

1)
glm1 <- glm(log(target) ~ . - offset_var,
data = dat.train,
offset = offset_var,
family = gaussian(link = "identity")
2)
glm1 <- glm(log(target) ~ . - log(offset_var),
data = dat.train,
offset = offset_var,
family = gaussian(link = "identity")
3)
glm1 <- glm(log(target) ~ . - log(offset_var),
data = dat.train,
offset = log(offset_var),
family = gaussian(link = "identity")

The model you described is really just an OLS and is using an identity link, not the log link like you implied.

To fit a true GLM I would use a non-transformed target variable modeled with a gamma distribution and a log link. You would then subtract offset_var (as it appears in the dataset, not log(offset_var)) from the model equation and set offset = log(offset_var) ("to make it on the same scale as the linear predictor." - manual).
See pages 226-227 of the manual for a better description and example.

To answer your question, I don't believe we should ever subtract log(offset_var) in the model equation. What I'm not sure about is if we should include offset = log(offset_var) or not in the case you described: log-transformed target variable with a normal dist. and identity link. That is, should the scale of the offset variable always match the link function, regardless of the transformation of the target variable. If that's true, then my answer would be scenario (1) is correct.
Reply With Quote
  #274  
Old Yesterday, 06:14 PM
Grace_IC Grace_IC is offline
SOA
 
Join Date: Apr 2020
Studying for PA
Posts: 2
Default R code error for running mean of predictore by different level

I tried to get the mean of predictor by different level, but always have a code error message: "Error: n() should only be called in a data context".

Can anyone help me figure out what it is the code issue? Or is there a alternative way to check the mean of predictor by different level?

12/2019 Exam:
library(dplyr)

df %>%
group_by(marital_status) %>%
summarise(
zeros = sum(value_flag == 0),
ones = sum(value_flag == 1),
n = n(),
proportion = mean(value_flag)
)

6/2019 Exam:
library(dplyr)

for (i in vars) {
print(i)
x <- dat %>% group_by_(i)%>%summarise(mean=mean(log(Crash_Score )),
median=median(log(Crash_Score)),
n = n())
print(x)
}
Reply With Quote
  #275  
Old Yesterday, 06:39 PM
ActuaryStudent22 ActuaryStudent22 is offline
SOA
 
Join Date: Feb 2020
Posts: 23
Default

Quote:
Originally Posted by Grace_IC View Post
I tried to get the mean of predictor by different level, but always have a code error message: "Error: n() should only be called in a data context".

Can anyone help me figure out what it is the code issue? Or is there a alternative way to check the mean of predictor by different level?

12/2019 Exam:
library(dplyr)

df %>%
group_by(marital_status) %>%
summarise(
zeros = sum(value_flag == 0),
ones = sum(value_flag == 1),
n = n(),
proportion = mean(value_flag)
)

6/2019 Exam:
library(dplyr)

for (i in vars) {
print(i)
x <- dat %>% group_by_(i)%>%summarise(mean=mean(log(Crash_Score )),
median=median(log(Crash_Score)),
n = n())
print(x)
}
You may find post #241 useful

Last edited by ActuaryStudent22; Yesterday at 06:43 PM..
Reply With Quote
  #276  
Old Yesterday, 08:11 PM
street5990 street5990 is offline
SOA
 
Join Date: Apr 2020
Posts: 15
Default

@ambroselo your method of the one standard rule for reducing tree complexity differs from the modules and am wondering which is correct. On slide 48 of module 7, the one standard error rule is applied by adding the xerror column and xstd column and selecting the CP corresponding to the smallest value of this sum. However, this differs from your approach applied for practice exam 1. If you were to use the module’s one standard error approach, by (dt$cptable[, "xerror"] + dt$cptable[, "xstd"]) you would get that the number of splits associated with the optimal complexity parameter is 7 (compared to your solution of split 1). So, what is the difference and which method should I use?

Last edited by street5990; Today at 10:05 AM..
Reply With Quote
  #277  
Old Today, 12:07 AM
Grace_IC Grace_IC is offline
SOA
 
Join Date: Apr 2020
Studying for PA
Posts: 2
Default

Quote:
Originally Posted by ActuaryStudent22 View Post
You may find post #241 useful
Thank you! It is really helpful!!!
Reply With Quote
  #278  
Old Today, 05:09 AM
debratee debratee is offline
SOA
 
Join Date: May 2020
College: University of Michigan, Ann Arbor
Posts: 8
Default

Dear Dr Ambrose,

I was trying the Hospital Readmissions sample exam and I kept running into this error where my model is rank deficient. Of course, in later steps after the stepAIC, it was all good. But I am just wondering,

1. Why is my model rank deficient - is it because of the interaction variable? PS: I used ER and Log HCC Riskscore, instead of Gender and Race given in the solution.

2. In general, if I face such a situation in the exam, how should I deal with it?

Appreciate your kind help! I attached the screenshot to show you what model I was running. Thanks!
Attached Images
 
Reply With Quote
  #279  
Old Today, 01:16 PM
mnm4156 mnm4156 is online now
Member
SOA
 
Join Date: Oct 2015
Posts: 71
Default

On your sample exam you state the following…

“For values of the cp parameter greater than the value supplied in the function call, the algorithm divides the training data into 10 folds, training the tree on all but one fold, and computing the R-squared on the held-out fold as the cross-validation error”

I am confused because I thought RSS was used as the impurity measure for regression trees. On page 308 of your manual you state "the six prediction errors are squared, summed, and divided by the total sum of errors to get xerror" indicating RSS is calculated on the heldout observation not R-squared. Can you please explain the difference between where the algorithm uses R-squared versus RSS?

Last edited by mnm4156; Today at 02:01 PM..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 03:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.17939 seconds with 10 queries