Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Carl Corder
acts-875
Commits
3a7b7d64
Commit
3a7b7d64
authored
Oct 27, 2019
by
Carl Corder
Browse files
Update transform_data_famd.r
parent
5f31326d
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/phase2/transform_data_famd.r
View file @
3a7b7d64
...
...
@@ -6,7 +6,6 @@ library("factoextra")
# phase 2 excel
input
<-
"C:/Users/its-student/Desktop/Phase2In.xlsx"
output
<-
"C:/Users/its-student/Desktop/Phase2OutFAMD.xlsx"
# read in sheets
data
<-
read_excel
(
input
,
sheet
=
"Data"
)
...
...
@@ -133,20 +132,8 @@ data <- data %>%
MAX_LIVES
>=
1000
&
TRUE_GROUP_VOL
==
"V"
&
POLICY_DURATION
<
4
~
1.0000
,
MAX_LIVES
>=
1000
&
TRUE_GROUP_VOL
==
"V"
&
POLICY_DURATION
>=
4
~
1.0200
))
# calculate needed premium
#data <- data %>% mutate(NEEDED_PREMIUM = PREM / RTN)
# calculate expected claims
#data <- data %>% mutate(EXPECTED_CLAIMS = NEEDED_PREMIUM * TLR)
# calcualte actual claims
#data <- data %>% mutate(ACTUAL_CLAIMS = PAID_CLAIMS + IBNR)
# calculate actual to expected ratio
#data <- data %>% mutate(ACTUAL_TO_EXPECTED = ACTUAL_CLAIMS / EXPECTED_CLAIMS)
# numerics -> pca + factors -> mca
# famd = pca (numerics) + mca (factors)
data
<-
data
%>%
select
(
"REGION"
,
"INDUSTRY"
,
"COVG_CODE"
,
"LTD_INDICATOR"
,
"AVG_SALARY"
,
"AVG_AGE"
,
"PCT_FEMALE"
,
...
...
@@ -156,9 +143,7 @@ data <- data %>% select("REGION", "INDUSTRY",
"PAID_COMMISSION"
,
"PAID_CLAIMS"
,
"CLAIM_COUNT"
,
"IBNR"
,
"PERCENT_COMMISSION"
,
"PREMIUM_TAX"
,
"INTERNAL_EXPENSES"
,
"PERCENT_PEPM"
)
save
(
data
,
file
=
"C:/Users/its-student/Desktop/phase2.rdata"
)
# use FactoMineR for PCA
# use FactoMineR for FAMD
data.famd
<-
FAMD
(
data
,
graph
=
FALSE
)
summary
(
data.famd
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment