This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.

####Quasi-poisson regression for the entire sample controlling for Megan's Law implementation
glm1 <- glm(Sex_Offense~meglaw+state+factor(year)+factor(month), 
            family=quasipoisson, data=subset(meglaw_widex,
                                             is.minor==1))
Warning messages:
1: In doTryCatch(return(expr), name, parentenv, handler) :
  display list redraw incomplete
2: In doTryCatch(return(expr), name, parentenv, handler) :
  invalid graphics state
3: In doTryCatch(return(expr), name, parentenv, handler) :
  invalid graphics state
4: In doTryCatch(return(expr), name, parentenv, handler) :
  display list redraw incomplete
5: In doTryCatch(return(expr), name, parentenv, handler) :
  invalid graphics state
6: In doTryCatch(return(expr), name, parentenv, handler) :
  invalid graphics state
summary(glm1)

Call:
glm(formula = Sex_Offense ~ meglaw + state + factor(year) + factor(month), 
    family = quasipoisson, data = subset(meglaw_widex, is.minor == 
        1))

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-4.7721  -1.3090  -0.4970   0.5335  24.4063  

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)    
(Intercept)       1.244660   0.129083   9.642  < 2e-16 ***
meglaw           -0.024172   0.032127  -0.752   0.4518    
stateCO          -1.409570   0.031163 -45.233  < 2e-16 ***
stateIA          -1.513954   0.031730 -47.713  < 2e-16 ***
stateID          -0.868607   0.081822 -10.616  < 2e-16 ***
stateMA          -2.272294   0.044023 -51.616  < 2e-16 ***
stateSC          -0.764407   0.025811 -29.615  < 2e-16 ***
stateTX          -1.558140   0.034489 -45.178  < 2e-16 ***
stateUT          -1.323945   0.034128 -38.793  < 2e-16 ***
stateVA          -1.160519   0.030447 -38.115  < 2e-16 ***
stateVT          -3.006023   0.080595 -37.298  < 2e-16 ***
factor(year)1993  0.937796   0.118981   7.882 3.41e-15 ***
factor(year)1994  1.010042   0.120590   8.376  < 2e-16 ***
factor(year)1995  0.836136   0.119652   6.988 2.89e-12 ***
factor(year)1996  0.828492   0.126607   6.544 6.16e-11 ***
factor(year)1997  1.320012   0.131609  10.030  < 2e-16 ***
factor(year)1998  1.578537   0.136982  11.524  < 2e-16 ***
factor(year)1999  1.683986   0.141733  11.881  < 2e-16 ***
factor(year)2000  1.727402   0.145340  11.885  < 2e-16 ***
factor(year)2001  1.792774   0.149573  11.986  < 2e-16 ***
factor(year)2002  1.913366   0.159175  12.021  < 2e-16 ***
factor(month).L  -0.158534   0.030897  -5.131 2.91e-07 ***
factor(month).Q  -0.223847   0.027467  -8.150 3.90e-16 ***
factor(month).C  -0.134718   0.027290  -4.937 8.02e-07 ***
factor(month)^4   0.114069   0.027259   4.185 2.87e-05 ***
factor(month)^5  -0.013815   0.027642  -0.500   0.6172    
factor(month)^6   0.005841   0.027724   0.211   0.8331    
factor(month)^7  -0.003159   0.027153  -0.116   0.9074    
factor(month)^8   0.060339   0.026842   2.248   0.0246 *  
factor(month)^9  -0.003880   0.026912  -0.144   0.8854    
factor(month)^10  0.024623   0.026643   0.924   0.3554    
factor(month)^11  0.044149   0.026141   1.689   0.0913 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for quasipoisson family taken to be 5.315651)

    Null deviance: 108763  on 17369  degrees of freedom
Residual deviance:  55407  on 17338  degrees of freedom
AIC: NA

Number of Fisher Scoring iterations: 5
####Quasi-poisson regression for the entire sample controlling for Megan's Law implementation AND that the victim is a minor 
glm1.minor <- glm(Sex_Offense~meglaw*state+factor(year)+factor(month), 
            family=quasipoisson, data=subset(meglaw_widex,
                                             is.minor==1))
summary(glm1.minor)

Call:
glm(formula = Sex_Offense ~ meglaw * state + factor(year) + factor(month), 
    family = quasipoisson, data = subset(meglaw_widex, is.minor == 
        1))

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-4.9356  -1.2678  -0.4494   0.4943  24.9398  

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)    
(Intercept)       1.227685   0.176672   6.949 3.81e-12 ***
meglaw            0.235264   0.045188   5.206 1.95e-07 ***
stateCO          -0.991037   0.054278 -18.259  < 2e-16 ***
stateIA          -1.210584   0.053265 -22.727  < 2e-16 ***
stateID          -0.851665   0.147489  -5.774 7.85e-09 ***
stateMA          -2.270003   0.079223 -28.653  < 2e-16 ***
stateSC          -0.366917   0.043603  -8.415  < 2e-16 ***
stateTX          -1.436693   0.059216 -24.262  < 2e-16 ***
stateUT          -1.039578   0.065535 -15.863  < 2e-16 ***
stateVA          -1.816995   0.078921 -23.023  < 2e-16 ***
stateVT          -2.430336   0.126825 -19.163  < 2e-16 ***
factor(year)1993  0.904655   0.130437   6.936 4.19e-12 ***
factor(year)1994  0.913794   0.167742   5.448 5.17e-08 ***
factor(year)1995  0.759042   0.167185   4.540 5.66e-06 ***
factor(year)1996  0.840795   0.171847   4.893 1.00e-06 ***
factor(year)1997  1.188650   0.177744   6.687 2.34e-11 ***
factor(year)1998  1.354829   0.180776   7.495 6.97e-14 ***
factor(year)1999  1.489625   0.182592   8.158 3.63e-16 ***
factor(year)2000  1.539538   0.183851   8.374  < 2e-16 ***
factor(year)2001  1.642006   0.186286   8.814  < 2e-16 ***
factor(year)2002  1.757774   0.193113   9.102  < 2e-16 ***
factor(month).L  -0.169644   0.030187  -5.620 1.94e-08 ***
factor(month).Q  -0.218995   0.026802  -8.171 3.27e-16 ***
factor(month).C  -0.134020   0.026611  -5.036 4.79e-07 ***
factor(month)^4   0.113004   0.026569   4.253 2.12e-05 ***
factor(month)^5  -0.012076   0.026951  -0.448   0.6541    
factor(month)^6   0.003671   0.027016   0.136   0.8919    
factor(month)^7  -0.003233   0.026467  -0.122   0.9028    
factor(month)^8   0.062272   0.026157   2.381   0.0173 *  
factor(month)^9  -0.006373   0.026230  -0.243   0.8080    
factor(month)^10  0.027460   0.025962   1.058   0.2902    
factor(month)^11  0.045025   0.025477   1.767   0.0772 .  
meglaw:stateCO   -0.581587   0.065739  -8.847  < 2e-16 ***
meglaw:stateIA   -0.434211   0.065552  -6.624 3.60e-11 ***
meglaw:stateID   -0.192027   0.130000  -1.477   0.1397    
meglaw:stateMA    0.024739   0.093335   0.265   0.7910    
meglaw:stateSC   -0.585658   0.052894 -11.072  < 2e-16 ***
meglaw:stateTX   -0.137377   0.070960  -1.936   0.0529 .  
meglaw:stateUT   -0.429197   0.075869  -5.657 1.56e-08 ***
meglaw:stateVA    0.774223   0.084946   9.114  < 2e-16 ***
meglaw:stateVT   -0.928318   0.163238  -5.687 1.31e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for quasipoisson family taken to be 5.047255)

    Null deviance: 108763  on 17369  degrees of freedom
Residual deviance:  53269  on 17329  degrees of freedom
AIC: NA

Number of Fisher Scoring iterations: 5

```

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Cmd+Option+I.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Cmd+Shift+K to preview the HTML file).

LS0tCnRpdGxlOiAiQWxleGlzIExlcnJvOiBNZWdhbidzIExhdyBSZWdyZXNzaW9uIgpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sKLS0tCgpUaGlzIGlzIGFuIFtSIE1hcmtkb3duXShodHRwOi8vcm1hcmtkb3duLnJzdHVkaW8uY29tKSBOb3RlYm9vay4gV2hlbiB5b3UgZXhlY3V0ZSBjb2RlIHdpdGhpbiB0aGUgbm90ZWJvb2ssIHRoZSByZXN1bHRzIGFwcGVhciBiZW5lYXRoIHRoZSBjb2RlLiAKClRyeSBleGVjdXRpbmcgdGhpcyBjaHVuayBieSBjbGlja2luZyB0aGUgKlJ1biogYnV0dG9uIHdpdGhpbiB0aGUgY2h1bmsgb3IgYnkgcGxhY2luZyB5b3VyIGN1cnNvciBpbnNpZGUgaXQgYW5kIHByZXNzaW5nICpDbWQrU2hpZnQrRW50ZXIqLiAKCmBgYHtyfQojIyMjUXVhc2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