
1. Re: Logistic Regression with R  Trying to compute using rollup that doesn't work
Yuriy Fal Feb 13, 2016 3:35 PM (in response to Ed Kukec)Hi Ed,
Your R script is indeed a Table Calculation that works
on a view with a granularity of the dimensions combination:
[Patient Type]  [Hospital]  [Unique Patient Visit Identifier].
One should retain the same granularity on each view
to get the results as expected  even if a particular field,
say [Unique Patient Visit Identifier], doesn't need to be shown.
Further aggregating (averaging) the results returned from R
requires Nested Table Calculations. Moreover, a subsequent
Table Calc Filter is required to show only one Mark on a view
per Patient Type & Hospital.
Please find the attached wb.
Hope it could help.
Yours,
Yuri

2. Re: Logistic Regression with R  Trying to compute using rollup that doesn't work
Ed Kukec Feb 16, 2016 5:55 AM (in response to Yuriy Fal)Thanks Yuri! Still don't get the use of the If First() == 0 function but it seems to have worked. Thanks again.
Ed

3. Re: Logistic Regression with R  Trying to compute using rollup that doesn't work
Yuriy Fal Feb 16, 2016 6:25 AM (in response to Ed Kukec)Hi Ed,
if first()==0 ... is a Table Calculation Filter (inside a calculation itself),
which effectively filters only the first row in a Table Calc Partition.
A Partition is defined by every unique value combinations
of all Dimensions on a view, which are not included in Addressing
(so they stay on the Partitioning) for a particular Table Calculation.
Hope this helps.
Yours,
Yuri

4. Re: Logistic Regression with R  Trying to compute using rollup that doesn't work
Ed Kukec Feb 16, 2016 7:02 AM (in response to Yuriy Fal)Thanks Yuri, makes sense. Last quick question if I may...apologies again for being a bit of a newbie with R so not sure about how to do certain things. Here's my GLM Model Script in Tableau that Predicts Admissions based on several predictor variables. In the script below, how do I output the results, ie odds ratios, standard errors and coefficients into an external file...say an Excel or CSV File. I've seen the function Write in R but I've tried it a few times and can't get the syntax to work. If you could add the necessary code below to export the results to a file called summary.csv on my C Drive, that would be great!
SCRIPT_REAL("
admitstatus < .arg1
age < as.factor(.arg2)
triagecode < as.factor(.arg3)
cci_score < .arg4
gender < as.factor(.arg5)
fit < glm(admitstatus ~ age + triagecode + cci_score + gender,family = binomial(logit))
prob < predict(fit,type = 'response')
fit$fitted
",
avg([Admit Status] ),attr([Age Group]),attr([Triagecode]), avg([Cci Score Without Age]), ATTR([Gender])
)
Thanks,
Ed