Skip to content

Instantly share code, notes, and snippets.

@michaelstepner
Last active February 28, 2016 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelstepner/ede889ea540048d4105c to your computer and use it in GitHub Desktop.
Save michaelstepner/ede889ea540048d4105c to your computer and use it in GitHub Desktop.
Julia GLM: Domain Error
using GLM, DataFrames, Distributions, NumericExtensions
dfpass = readtable("test_domainerror_pass.csv")
dffail = readtable("test_domainerror_fail.csv")
glm(mortrate ~ age_at_d, dfpass, Binomial(), LogLink(), wts=[float(convert(Array, dfpass[:count]))])
glm(mortrate ~ age_at_d, dffail, Binomial(), LogLink(), wts=[float(convert(Array, dffail[:count]))], start=(-10,0.1))
glm(mortrate ~ age_at_d, dffail, Binomial(), LogLink(), wts=[float(convert(Array, dffail[:count]))])
dfpass = read.table("test_domainerror_pass.csv", header=TRUE, sep=",")
dffail = read.table("test_domainerror_fail.csv", header=TRUE, sep=",")
glm(mortrate ~ age_at_d, dfpass, family=binomial(link = "log"), weights=dfpass[, "count"])
glm(mortrate ~ age_at_d, dffail, family=binomial(link = "log"), weights=dffail[, "count"], start=c(-10,0.1))
glm(mortrate ~ age_at_d, dffail, family=binomial(link = "log"), weights=dffail[, "count"])
mortrate age_at_d count grp
1 40 64 12
0 40 18050 12
1 41 73 12
0 41 19240 12
1 42 80 12
0 42 19913 12
1 43 91 12
0 43 19218 12
1 44 83 12
0 44 18701 12
1 45 88 12
0 45 18627 12
1 46 98 12
0 46 18869 12
1 47 116 12
0 47 19442 12
1 48 154 12
0 48 20436 12
1 49 154 12
0 49 20617 12
1 50 177 12
0 50 20692 12
1 51 167 12
0 51 20735 12
1 52 169 12
0 52 20695 12
1 53 192 12
0 53 20359 12
1 54 184 12
0 54 19982 12
1 55 202 12
0 55 20030 12
1 56 221 12
0 56 19435 12
1 57 219 12
0 57 18754 12
1 58 234 12
0 58 18365 12
1 59 217 12
0 59 17591 12
1 60 217 12
0 60 17143 12
1 61 240 12
0 61 16376 12
1 62 214 12
0 62 15521 12
1 63 195 12
0 63 15245 12
mortrate age_at_d count grp
1 40 61 11
0 40 19229 11
1 41 94 11
0 41 19898 11
1 42 84 11
0 42 19204 11
1 43 105 11
0 43 18688 11
1 44 111 11
0 44 18605 11
1 45 114 11
0 45 18857 11
1 46 132 11
0 46 19445 11
1 47 130 11
0 47 20498 11
1 48 139 11
0 48 20673 11
1 49 140 11
0 49 20790 11
1 50 153 11
0 50 20827 11
1 51 167 11
0 51 20784 11
1 52 174 11
0 52 20479 11
1 53 192 11
0 53 20116 11
1 54 191 11
0 54 20185 11
1 55 185 11
0 55 19642 11
1 56 214 11
0 56 18886 11
1 57 199 11
0 57 18552 11
1 58 205 11
0 58 17760 11
1 59 209 11
0 59 17335 11
1 60 205 11
0 60 16595 11
1 61 205 11
0 61 15688 11
1 62 195 11
0 62 15466 11
1 63 209 11
0 63 15055 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment