knitr::opts_chunk$set(echo = TRUE,message=FALSE, warning=FALSE)

UBICACION DE PERROS EN ASA

#LIBRERIAS
library(plyr)
library(readxl)
library(data.table)
library(tidyverse)
library(ggplot2)
library(httr)
library(dplyr)
library(cowplot)

#BASE DE DATOS
PERROS_TOTAL<- read_excel("F:/BUSQUEDA PERROS/BUSQUEDA-DE-PERROS/DATOS PERROS.xlsx",
                  sheet = "DATOS_GENERAL")

poligonos<- read_excel("F:/BUSQUEDA PERROS/BUSQUEDA-DE-PERROS/ASA.xlsx")

##COMPARACION DE PERROS ENCONTRADOS ENTRE BUSCADORES

#URB. APURIMAC
PERROS.34<-filter(PERROS_TOTAL, ZONA=="URB. APURIMAC")
PERROS.34<-select( PERROS.34,CODIGO_PERRO, BUSCADOR, ZONA)
PERROS.34<-na.omit( PERROS.34)

userA <- PERROS.34[PERROS.34$BUSCADOR=="3",]
userB <- PERROS.34[PERROS.34$BUSCADOR=="9",]
userC <- PERROS.34[PERROS.34$BUSCADOR=="2",]
userD <- PERROS.34[PERROS.34$BUSCADOR=="1",]
userGS <- PERROS.34[PERROS.34$BUSCADOR=="GS",]

#Merge entre busquedas

resultAxB <- merge(userA, userB, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxC <- merge(userA, userC,by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxD <- merge(userA, userC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultBxC <- merge(userB, userC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultBxD <- merge(userB, userD, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultCxD <- merge(userA, userC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)

resultAxBxC <- merge(userC,resultAxB, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultBxCxD <- merge(userD, resultBxC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxBxD <- merge(userA, resultBxD, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxCxD <- merge(userA, resultCxD, by=c("CODIGO_PERRO","ZONA"), all=TRUE)

resultAxBxCxD <- merge(userD,resultAxBxC ,by=c("CODIGO_PERRO","ZONA"), all=TRUE)

#colocar combinaciones en un data frame para graficar
resultAxB=cbind(resultAxB,Busqueda=rep("3x4",80))
resultAxB<- select(resultAxB,CODIGO_PERRO,Busqueda,ZONA)

resultAxC=cbind(resultAxC,Busqueda=rep("3x2",68))
resultAxC<- select(resultAxC,CODIGO_PERRO,Busqueda,ZONA)

resultAxD=cbind(resultAxD,Busqueda=rep("3x1",68))
resultAxD<- select(resultAxD,CODIGO_PERRO,Busqueda,ZONA)

resultBxC=cbind(resultBxC,Busqueda=rep("4x2",81))
resultBxC<- select(resultBxC,CODIGO_PERRO,Busqueda,ZONA)

resultBxD=cbind(resultBxD,Busqueda=rep("4x1",80))
resultBxD<- select(resultBxD,CODIGO_PERRO,Busqueda,ZONA)

resultCxD=cbind(resultCxD,Busqueda=rep("2x1",68))
resultCxD<- select(resultCxD,CODIGO_PERRO,Busqueda,ZONA)

resultAxBxC=cbind(resultAxBxC,Busqueda=rep("3x4x2",82))
resultAxBxC<- select(resultAxBxC,CODIGO_PERRO,Busqueda,ZONA)

resultAxBxD=cbind(resultAxBxD,Busqueda=rep("3x4x1",80))
resultAxBxD<- select(resultAxBxD,CODIGO_PERRO,Busqueda,ZONA)

resultBxCxD=cbind(resultBxCxD,Busqueda=rep("4x2x1",82))
resultBxCxD<- select(resultBxCxD,CODIGO_PERRO,Busqueda,ZONA)

resultAxCxD=cbind(resultAxCxD,Busqueda=rep("3x2x1",68))
resultAxCxD<- select(resultAxCxD,CODIGO_PERRO,Busqueda,ZONA)

resultAxBxCxD=cbind(resultAxBxCxD,Busqueda=rep("3x4x2x1",82))
resultAxBxCxD<- select(resultAxBxCxD,CODIGO_PERRO,Busqueda,ZONA)

##Cambiar nombre a columna para unir
names(userA)[2]="Busqueda"
names(userB)[2]="Busqueda"
names(userC)[2]="Busqueda"
names(userD)[2]="Busqueda"
names(userGS)[2]="Busqueda"

grafica.34<-rbind(resultAxB,resultAxC,resultAxD,resultBxC,resultBxD,resultCxD, 
                  resultAxBxC,resultAxBxD,resultBxCxD,resultAxCxD,resultAxBxCxD, 
                  userA,userB,userC,userD,userGS)

grafica.34count<-grafica.34%>%count(Busqueda)
grafica.34count<-grafica.34count%>%arrange(desc(n))%>%
  mutate(Busqueda=factor(Busqueda,level=Busqueda))

#grafica de buscadores en combinacion

ggplot(grafica.34count,aes(x=Busqueda,y=n))+
  geom_bar(aes(),stat = "identity",position="dodge") + labs(x="BUSCADOR",y="PERROS", 
       title="PERROS ENCONTRADOS EN URB. APURIMAC") + coord_flip() 

## VILLA CONFRATERNIDAD ZONA B III MARGEN DERECHO
PERROS.95<-filter(PERROS_TOTAL, ZONA=="VILLA CONFRATERNIDAD ZONA B III MARGEN DERECHO")
PERROS.95<-select( PERROS.95,CODIGO_PERRO, BUSCADOR, ZONA)
PERROS.95<-na.omit(PERROS.95)

userA <- PERROS.95[PERROS.95$BUSCADOR=="1",]
userB <- PERROS.95[PERROS.95$BUSCADOR=="2",]
userC <- PERROS.95[PERROS.95$BUSCADOR=="5",]
userD <- PERROS.95[PERROS.95$BUSCADOR=="3",]
userGS <- PERROS.95[PERROS.95$BUSCADOR=="GS",]

#Merge entre busquedas

resultAxB <- merge(userA, userB, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxC <- merge(userA, userC,by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxD <- merge(userA, userC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultBxC <- merge(userB, userC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultBxD <- merge(userB, userD, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultCxD <- merge(userA, userC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)

resultAxBxC <- merge(userC,resultAxB, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultBxCxD <- merge(userD, resultBxC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxBxD <- merge(userA, resultBxD, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxCxD <- merge(userA, resultCxD, by=c("CODIGO_PERRO","ZONA"), all=TRUE)

resultAxBxCxD <- merge(userD,resultAxBxC ,by=c("CODIGO_PERRO","ZONA"), all=TRUE)

#colocar combinaciones en un data frame para graficar

resultAxB=cbind(resultAxB,Busqueda=rep("1x2",33))
resultAxB<- select(resultAxB,CODIGO_PERRO,Busqueda,ZONA)

resultAxC=cbind(resultAxC,Busqueda=rep("1x5",29))
resultAxC<- select(resultAxC,CODIGO_PERRO,Busqueda,ZONA)

resultAxD=cbind(resultAxD,Busqueda=rep("1x3",29))
resultAxD<- select(resultAxD,CODIGO_PERRO,Busqueda,ZONA)

resultBxC=cbind(resultBxC,Busqueda=rep("2x5",34))
resultBxC<- select(resultBxC,CODIGO_PERRO,Busqueda,ZONA)

resultBxD=cbind(resultBxD,Busqueda=rep("2x3",33))
resultBxD<- select(resultBxD,CODIGO_PERRO,Busqueda,ZONA)

resultCxD=cbind(resultCxD,Busqueda=rep("5x3",29))
resultCxD<- select(resultCxD,CODIGO_PERRO,Busqueda,ZONA)

resultAxBxC=cbind(resultAxBxC,Busqueda=rep("1x2x5",34))
resultAxBxC<- select(resultAxBxC,CODIGO_PERRO,Busqueda,ZONA)

resultAxBxD=cbind(resultAxBxD,Busqueda=rep("1x2x3",35))
resultAxBxD<- select(resultAxBxD,CODIGO_PERRO,Busqueda,ZONA)

resultBxCxD=cbind(resultBxCxD,Busqueda=rep("2x5x3",36))
resultBxCxD<- select(resultBxCxD,CODIGO_PERRO,Busqueda,ZONA)

resultAxCxD=cbind(resultAxCxD,Busqueda=rep("1x5x3",29))
resultAxCxD<- select(resultAxCxD,CODIGO_PERRO,Busqueda,ZONA)

resultAxBxCxD=cbind(resultAxBxCxD,Busqueda=rep("1x2x5x3",36))
resultAxBxCxD<- select(resultAxBxCxD,CODIGO_PERRO,Busqueda,ZONA)

##Cambiar nombre a columna para unir
names(userA)[2]="Busqueda"
names(userB)[2]="Busqueda"
names(userC)[2]="Busqueda"
names(userD)[2]="Busqueda"
names(userGS)[2]="Busqueda"

grafica.95<-rbind(resultAxB,resultAxC,resultAxD,resultBxC,resultBxD,resultCxD, 
                  resultAxBxC,resultAxBxD,resultBxCxD,resultAxCxD,resultAxBxCxD, 
                  userA,userB,userC,userD,userGS)

grafica.95count<-grafica.95%>%count(Busqueda)
grafica.95count<-grafica.95count%>%arrange(desc(n))%>%
  mutate(Busqueda=factor(Busqueda,level=Busqueda))

#grafica de buscadores en combinacion

ggplot(grafica.95count,aes(x=Busqueda,y=n))+
  geom_bar(aes(),stat = "identity",position="dodge") +
  labs(x="BUSCADOR",y="PERROS", title="PERROS ENCONTRADOS EN VILLA CONFRATERNIDAD 
       ZONA B III MARGEN DERECHO") +
  coord_flip()  

## ALTO SELVA ALEGRE ZONA A
PERROS.1<-filter(PERROS_TOTAL, ZONA=="ALTO SELVA ALEGRE ZONA A")
PERROS.1<-select( PERROS.1,CODIGO_PERRO, BUSCADOR, ZONA)
PERROS.1<-na.omit(PERROS.1)

userA <- PERROS.1[PERROS.1$BUSCADOR=="19",]
userB <- PERROS.1[PERROS.1$BUSCADOR=="26",]
userC <- PERROS.1[PERROS.1$BUSCADOR=="3",]
userD <- PERROS.1[PERROS.1$BUSCADOR=="2",]
userGS <- PERROS.1[PERROS.1$BUSCADOR=="GS",]

#Merge entre busquedas

resultAxB <- merge(userA, userB, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxC <- merge(userA, userC,by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxD <- merge(userA, userC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultBxC <- merge(userB, userC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultBxD <- merge(userB, userD, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultCxD <- merge(userA, userC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)

resultAxBxC <- merge(userC,resultAxB, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultBxCxD <- merge(userD, resultBxC, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxBxD <- merge(userA, resultBxD, by=c("CODIGO_PERRO","ZONA"), all=TRUE)
resultAxCxD <- merge(userA, resultCxD, by=c("CODIGO_PERRO","ZONA"), all=TRUE)

resultAxBxCxD <- merge(userD,resultAxBxC ,by=c("CODIGO_PERRO","ZONA"), all=TRUE)

#colocar combinaciones en un data frame para graficar

resultAxB=cbind(resultAxB,Busqueda=rep("19x26",44))
resultAxB<- select(resultAxB,CODIGO_PERRO,Busqueda,ZONA)

resultAxC=cbind(resultAxC,Busqueda=rep("19x3",52))
resultAxC<- select(resultAxC,CODIGO_PERRO,Busqueda,ZONA)

resultAxD=cbind(resultAxD,Busqueda=rep("19x2",52))
resultAxD<- select(resultAxD,CODIGO_PERRO,Busqueda,ZONA)

resultBxC=cbind(resultBxC,Busqueda=rep("26x3",45))
resultBxC<- select(resultBxC,CODIGO_PERRO,Busqueda,ZONA)

resultBxD=cbind(resultBxD,Busqueda=rep("26x2",58))
resultBxD<- select(resultBxD,CODIGO_PERRO,Busqueda,ZONA)

resultCxD=cbind(resultCxD,Busqueda=rep("3x2",52))
resultCxD<- select(resultCxD,CODIGO_PERRO,Busqueda,ZONA)

resultAxBxC=cbind(resultAxBxC,Busqueda=rep("19x26x3",56))
resultAxBxC<- select(resultAxBxC,CODIGO_PERRO,Busqueda,ZONA)

resultAxBxD=cbind(resultAxBxD,Busqueda=rep("19x26x2",63))
resultAxBxD<- select(resultAxBxD,CODIGO_PERRO,Busqueda,ZONA)

resultBxCxD=cbind(resultBxCxD,Busqueda=rep("26x3x2",65))
resultBxCxD<- select(resultBxCxD,CODIGO_PERRO,Busqueda,ZONA)

resultAxCxD=cbind(resultAxCxD,Busqueda=rep("19x3x2",52))
resultAxCxD<- select(resultAxCxD,CODIGO_PERRO,Busqueda,ZONA)

resultAxBxCxD=cbind(resultAxBxCxD,Busqueda=rep("19x26x3x2",69))
resultAxBxCxD<- select(resultAxBxCxD,CODIGO_PERRO,Busqueda,ZONA)

##Cambiar nombre a columna para unir
names(userA)[2]="Busqueda"
names(userB)[2]="Busqueda"
names(userC)[2]="Busqueda"
names(userD)[2]="Busqueda"
names(userGS)[2]="Busqueda"

grafica.1<-rbind(resultAxB,resultAxC,resultAxD,resultBxC,resultBxD,resultCxD, 
                 resultAxBxC,resultAxBxD,resultBxCxD,resultAxCxD,resultAxBxCxD, 
                 userA,userB,userC,userD,userGS)

grafica.1count<-grafica.1%>%count(Busqueda)
grafica.1count<-grafica.1count%>%arrange(desc(n))%>%
  mutate(Busqueda=factor(Busqueda,level=Busqueda))

#grafica de buscadores en combinacion

ggplot(grafica.1count,aes(x=Busqueda,y=n))+
  geom_bar(aes(),stat = "identity",position="dodge") +
  labs(x="BUSCADOR",y="PERROS", 
       title="PERROS ENCONTRADOS EN URB. ALTO SELVA ALEGRE ZONA A") +
  coord_flip() 

CORRELACION ENTRE PERROS ENCUESTAS Y PERROS STREET VIEW

PERROS CON ACCESO A LA CALLE ENCUESTAS

#CARGANDO BASES DE DATOS
ENCUESTA.PERROS<- read_excel("F:/BUSQUEDA PERROS/BUSQUEDA-DE-PERROS/ENCUESTA PERROS.xlsx") 
PERROS_GOOGLE<- read_excel("F:/BUSQUEDA PERROS/BUSQUEDA-DE-PERROS/DATOS PERROS.xlsx", 
                           sheet = "GOLD_STANDARD")

PRUEBA_PERROS<- read_excel("F:/BUSQUEDA PERROS/BUSQUEDA-DE-PERROS/DATOS PERROS.xlsx", 
                           sheet = "KM")

#filtrar perros deambulantes encuestas
ENC_PERROS_LIB.ACCE<-filter(ENCUESTA.PERROS,ACCESO_CALLE=="SI")

#filtrar perros GSV
PERROS_GSV<-filter(PERROS_GOOGLE,BUSQUEDA=="GS")
PERROS_GSV<-filter(PERROS_GSV, ZONA=="CONQUISTADOR II"|
                     ZONA=="A.A.H.H. JAVIER HERAUD PAMPAS POLANCO" |
                     ZONA=="VILLA FLORIDA"|ZONA=="VILLA SALVADOR"|
                     ZONA=="INDEPENDENCIA ZONA A I"|ZONA=="URB. APURIMAC"|
                     ZONA=="EL MIRADOR P. POLANCO"|ZONA=="AA. HH. PRIMERO DE ENERO"|
                     ZONA=="ANTONIO JOSE DE SUCRE"|ZONA=="AMPLIACION VILLA UNION"|
                     ZONA=="ASOC. ARTESANAL EL MISTI"|
                     ZONA=="ASOCIACION VILLA VITARTE Y SAN HILARION"|
                     ZONA=="AVIS JUAN VELASCO ALVARADO A"|ZONA=="COOP. CRUCE CHILINA"|
                     ZONA=="CONQUISTADOR II"|ZONA=="COOP. DE VIV. ENATRU"|
                     ZONA=="COOP. DE VIV. LOS EUCALIPTOS"|
                     ZONA=="HABITACION URBANA PROGRESIVA SE搼㸱OR DE LOS PIEDADES"|
                     ZONA=="PAMPA CHICA"|ZONA=="UPIS SAN LUIS"|
                     ZONA=="VILLA CONFRATERNIDAD B-II"|
                     ZONA=="VILLA CONFRATERNIDAD ZONA B III MARGEN DERECHO"|
                     ZONA=="VILLA ECOLOGICA ZONA C I MARGEN DERECHO"|
                     ZONA=="VILLA ECOLOGICA ZONA C II MARGEN IZQUIERDO"|
                     ZONA=="VILLA ECOLOGICA ZONA D-1"|ZONA=="VILLA ECOLOGICA ZONA D-2 MARGEN DERECHO"|
                     ZONA=="VILLAS CHACHAS")

#filtrar zonas por km y area

PERROS_KM<-filter(PRUEBA_PERROS, ZONA=="CONQUISTADOR II"|
                    ZONA=="A.A.H.H. JAVIER HERAUD PAMPAS POLANCO" |
                    ZONA=="VILLA FLORIDA"|ZONA=="VILLA SALVADOR"|
                    ZONA=="INDEPENDENCIA ZONA A I"|ZONA=="URB. APURIMAC"|
                    ZONA=="EL MIRADOR P. POLANCO"|ZONA=="AA. HH. PRIMERO DE ENERO"|
                    ZONA=="ANTONIO JOSE DE SUCRE"|ZONA=="AMPLIACION VILLA UNION"|
                    ZONA=="ASOC. ARTESANAL EL MISTI"|
                    ZONA=="ASOCIACION VILLA VITARTE Y SAN HILARION"|
                    ZONA=="AVIS JUAN VELASCO ALVARADO A"|ZONA=="COOP. CRUCE CHILINA"|
                    ZONA=="CONQUISTADOR II"|ZONA=="COOP. DE VIV. ENATRU"|
                    ZONA=="COOP. DE VIV. LOS EUCALIPTOS"|
                    ZONA=="HABITACION URBANA PROGRESIVA SE搼㸱OR DE LOS PIEDADES"|
                    ZONA=="PAMPA CHICA"|ZONA=="UPIS SAN LUIS"|
                    ZONA=="VILLA CONFRATERNIDAD B-II"|
                    ZONA=="VILLA CONFRATERNIDAD ZONA B III MARGEN DERECHO"|
                    ZONA=="VILLA ECOLOGICA ZONA C I MARGEN DERECHO"|
                    ZONA=="VILLA ECOLOGICA ZONA C II MARGEN IZQUIERDO"|
                    ZONA=="VILLA ECOLOGICA ZONA D-1"|ZONA=="VILLA ECOLOGICA ZONA D-2 MARGEN DERECHO"|
                    ZONA=="VILLAS CHACHAS")

#creando data.frame de KM Y AREA
PERROS_KM<-select(PERROS_KM,ZONA,AREA, KILOMETROS)

#creando data.frame de perros encuesta zona /perro
ENC_PERROS_LIB.ACCE<-select(ENC_PERROS_LIB.ACCE,ZONA)

ENC_PERROS_LIB.ACCE$ZONA<-as.factor(ENC_PERROS_LIB.ACCE$ZONA)
ENC_PERROS_LIB.ACCE<-as.data.frame(table(ENC_PERROS_LIB.ACCE))

colnames(ENC_PERROS_LIB.ACCE)[1] <- "ZONA"
colnames(ENC_PERROS_LIB.ACCE)[2] <- "PERROS.ENC"
ENC_PERROS_LIB.ACCE$ZONA<-as.factor(ENC_PERROS_LIB.ACCE$ZONA)

#   CREANDO DATA FRAME PERROS GSV
PERROS_GSV<-select(PERROS_GSV,ZONA)
PERROS_GSV<-as.data.frame(table(PERROS_GSV))

colnames(PERROS_GSV)[1] <- "ZONA"
colnames(PERROS_GSV)[2] <- "PERROS.GSV"
PERROS_GSV$ZONA<-as.factor(PERROS_GSV$ZONA)

#merge 

PERROS_LIB.ACCE.1<-merge(ENC_PERROS_LIB.ACCE,PERROS_GSV,by="ZONA")

PERROS_LIB.ACCE.1<-merge(PERROS_LIB.ACCE.1,PERROS_KM,by="ZONA")

#distribucion normal
par(mfrow=c(1,2))
hist(PERROS_LIB.ACCE.1$PERROS.GSV, xlab = "PERROS.GSV", ylab = "ZONAS")
hist(PERROS_LIB.ACCE.1$PERROS.ENC, xlab = "PERROS.ENC", ylab = "ZONAS")

#correlaci昼㸳n de Spearman
cor(x=PERROS_LIB.ACCE.1$PERROS.GSV,y=PERROS_LIB.ACCE.1$PERROS.ENC 
    , method = "spearman")
## [1] 0.5892893
#GRAFICAS
PERROS_FREE<-ggplot(data=PERROS_LIB.ACCE.1,aes(PERROS.GSV,PERROS.ENC )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="PERROS LIBRE ACCESO ENCUESTAS Y PERROS STREET VIEW")+
        geom_text(data=PERROS_LIB.ACCE.1,x=75,y=20,label="??=0.6202706")

PERROS_FREE

PERROS CON ACCESO A LA CALLE O PASEAN SIN CORREA ENCUESTAS

ENC_PERROS_SIN.CORREA<-filter(ENCUESTA.PERROS,ACCESO_CALLE=="SI"|PASEAN=="SI"& CORREA=="NO")

#crenado data.frame de perros encuesta sin correa y libre acceso zona /perro
ENC_PERROS_SIN.CORREA<-select(ENC_PERROS_SIN.CORREA,ZONA)

ENC_PERROS_SIN.CORREA$ZONA<-as.factor( ENC_PERROS_SIN.CORREA$ZONA)
ENC_PERROS_SIN.CORREA<-as.data.frame(table(ENC_PERROS_SIN.CORREA))

colnames(ENC_PERROS_SIN.CORREA)[1] <- "ZONA"
colnames(ENC_PERROS_SIN.CORREA)[2] <- "PERROS.ENC.SIN.COR"
ENC_PERROS_SIN.CORREA$ZONA<-as.factor(ENC_PERROS_SIN.CORREA$ZONA)

#merge 

PERROS_SIN.CORREA.1<-merge(ENC_PERROS_SIN.CORREA,PERROS_GSV,by="ZONA")

PERROS_SIN.CORREA.1<-merge(PERROS_SIN.CORREA.1,PERROS_KM,by="ZONA")

#distribucion normal
hist(PERROS_SIN.CORREA.1$PERROS.ENC , xlab = "PERROS.ENC.SIN.COR", ylab = "ZONAS")

#correlaci昼㸳n de spearman
cor(x=PERROS_SIN.CORREA.1$PERROS.GSV,y=PERROS_SIN.CORREA.1$PERROS.ENC.SIN.COR 
    , method = "spearman")
## [1] 0.6164806
#GRAFICAS
PERROS.SIN.CORR<-ggplot(data=PERROS_SIN.CORREA.1,aes(PERROS.GSV,PERROS.ENC.SIN.COR )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="PERROS ENCUESTAS CON LIBRE ACCESO
       Y/O PASEAN SIN CORREA")+
  geom_text(data=PERROS_SIN.CORREA.1,x=75,y=20,label="??=0.6542872")

PERROS.SIN.CORR

PERROS POBLACION TOTAL ENCUESTAS

#creando data.frame de perros totales encuesta zona /perro
ENC_PERROS_TOTAL<-select(ENCUESTA.PERROS,ZONA)

ENC_PERROS_TOTAL$ZONA<-as.factor( ENC_PERROS_TOTAL$ZONA)
ENC_PERROS_TOTAL<-as.data.frame(table(ENC_PERROS_TOTAL))

colnames(ENC_PERROS_TOTAL)[1] <- "ZONA"
colnames(ENC_PERROS_TOTAL)[2] <- "PERROS.ENC.TOT"
ENC_PERROS_TOTAL$ZONA<-as.factor(ENC_PERROS_TOTAL$ZONA)

#merge

PERROS_TOTAL.1<-merge(ENC_PERROS_TOTAL,PERROS_GSV,by="ZONA")

PERROS_TOTAL.1<-merge(PERROS_TOTAL.1,PERROS_KM,by="ZONA")

#distribuci昼㸳n normal
hist(PERROS_TOTAL.1$PERROS.ENC, xlab = "PERROS.ENC.TOT", ylab = "ZONAS")

#correlaci昼㸳n de spearman
cor(x=PERROS_TOTAL.1$PERROS.GSV,y=PERROS_TOTAL.1$PERROS.ENC.TOT 
    , method = "spearman")
## [1] 0.4938415
#GRAFICAS
PERROS_TOTAL<-ggplot(data=PERROS_TOTAL.1,aes(PERROS.GSV,PERROS.ENC.TOT )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="POBLACION TOTAL PERROS ENCUESTAS")+
  geom_text(data=PERROS_TOTAL.1,x=75,y=20,label="??=0.5412248")

PERROS_TOTAL

MODELOS PARA PERROS LIBRE ACCESO ENCUESTAS Y PERROS STREET VIEW

#MODELO 0
modelo_0<- glm(PERROS.ENC ~ PERROS.GSV,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_0)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.1921  -2.9152  -0.0138   1.7337   6.4860  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 2.761322   0.067566   40.87   <2e-16 ***
## PERROS.GSV  0.021240   0.001308   16.24   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 232.65  on 23  degrees of freedom
## AIC: 364.66
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_0)

#MODELO 1
modelo_1<- glm(PERROS.ENC ~ PERROS.GSV + KILOMETROS ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_1)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV + KILOMETROS, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.8402  -2.2566  -0.3532   1.4037   6.0709  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 2.824754   0.065876  42.880  < 2e-16 ***
## PERROS.GSV  0.002635   0.003976   0.663    0.507    
## KILOMETROS  0.235276   0.047552   4.948 7.51e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 207.26  on 22  degrees of freedom
## AIC: 341.27
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_1)

#MODELO 2
modelo_2<- glm(PERROS.ENC ~ PERROS.GSV +  offset(log(KILOMETROS)) ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_2)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.0854  -1.4080  -0.9239   1.5056   6.3277  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  2.804525   0.067540  41.524   <2e-16 ***
## PERROS.GSV  -0.001728   0.001307  -1.322    0.186    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 211.34  on 24  degrees of freedom
## Residual deviance: 209.58  on 23  degrees of freedom
## AIC: 341.59
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_2)

#MODELO 3
modelo_3<- glm(PERROS.ENC ~ PERROS.GSV +  AREA ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_3)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV + AREA, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.3401  -2.6395  -0.2109   2.0613   6.4704  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 2.7968242  0.0650194  43.015  < 2e-16 ***
## PERROS.GSV  0.0089184  0.0023785   3.750 0.000177 ***
## AREA        0.0041657  0.0006988   5.962  2.5e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 198.38  on 22  degrees of freedom
## AIC: 332.4
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_3)

#MODELO 4
modelo_4<- glm(PERROS.ENC ~ PERROS.GSV +  offset(log(AREA)) ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_4)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV + offset(log(AREA)), family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.0006  -2.0774   0.6914   1.4910   6.4030  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -0.8721020  0.0648326 -13.452   <2e-16 ***
## PERROS.GSV  -0.0004912  0.0012371  -0.397    0.691    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 218.96  on 24  degrees of freedom
## Residual deviance: 218.80  on 23  degrees of freedom
## AIC: 350.82
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_4)

#MODELO 5
modelo_5<- glm(PERROS.ENC ~ PERROS.GSV + KILOMETROS + AREA ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_5)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV + KILOMETROS + AREA, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.4600  -2.7512  -0.2285   1.9215   6.3067  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 2.8159234  0.0657169  42.849  < 2e-16 ***
## PERROS.GSV  0.0042694  0.0039603   1.078 0.281013    
## KILOMETROS  0.0923866  0.0626312   1.475 0.140189    
## AREA        0.0032516  0.0009468   3.434 0.000594 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 196.17  on 21  degrees of freedom
## AIC: 332.18
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_5)

MODELO PARA PERROS LIBRE ACCESO ENCUESTAS Y/O PERROS QUE PASEAN SIN CORREA Y PERROS STREET VIEW

#MODELO 6
modelo_6<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_6)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV, family = poisson(link = "log"), 
##     data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -7.825  -2.350  -0.517   2.541   6.420  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 3.3064792  0.0485794   68.06   <2e-16 ***
## PERROS.GSV  0.0248533  0.0008999   27.62   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  317.18  on 23  degrees of freedom
## AIC: 468.05
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_6)

#MODELO 7
modelo_7<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV + KILOMETROS ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_7)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV + KILOMETROS, family = poisson(link = "log"), 
##     data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -4.912  -2.589  -1.125   1.902   5.656  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  3.407132   0.047009  72.479   <2e-16 ***
## PERROS.GSV  -0.000477   0.002865  -0.167    0.868    
## KILOMETROS   0.314236   0.033900   9.269   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  226.39  on 22  degrees of freedom
## AIC: 379.26
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_7)

#MODELO 8
modelo_8<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV +  offset(log(KILOMETROS)) ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_8)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -6.499  -1.765  -1.025   2.335   8.184  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 3.3500735  0.0485129  69.055   <2e-16 ***
## PERROS.GSV  0.0018767  0.0008983   2.089   0.0367 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 250.08  on 24  degrees of freedom
## Residual deviance: 245.74  on 23  degrees of freedom
## AIC: 396.61
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_8)

#MODELO 9
modelo_9<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV +  AREA ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_9)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV + AREA, family = poisson(link = "log"), 
##     data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.7607  -2.0110  -0.4342   2.5436   6.3321  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 3.3394538  0.0480914  69.440  < 2e-16 ***
## PERROS.GSV  0.0185178  0.0017858  10.369  < 2e-16 ***
## AREA        0.0020628  0.0005111   4.036 5.43e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  301.18  on 22  degrees of freedom
## AIC: 454.05
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_9)

#MODELO 10
modelo_10<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV +  offset(log(AREA)) ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_10)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV + offset(log(AREA)), 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -10.7118   -1.7649    0.8781    2.4608    7.6263  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -0.3099802  0.0466976  -6.638 3.18e-11 ***
## PERROS.GSV   0.0027542  0.0008542   3.224  0.00126 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 530.10  on 24  degrees of freedom
## Residual deviance: 519.78  on 23  degrees of freedom
## AIC: 670.65
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_10)

#MODELO 11
modelo_11<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV + KILOMETROS + AREA ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_11)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV + KILOMETROS + 
##     AREA, family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -4.896  -2.432  -1.096   2.520   5.476  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  3.3929650  0.0477016  71.129  < 2e-16 ***
## PERROS.GSV  -0.0020253  0.0029303  -0.691    0.489    
## KILOMETROS   0.4583500  0.0505545   9.066  < 2e-16 ***
## AREA        -0.0032181  0.0008245  -3.903 9.49e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  210.19  on 21  degrees of freedom
## AIC: 365.06
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_11)

MODELO PARA POBLACION TOTAL PERROS ENCUESTAS Y PERROS STREET VIEW

#MODELO 12
modelo_12<- glm(PERROS.ENC.TOT ~ PERROS.GSV,
               family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_12)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV, family = poisson(link = "log"), 
##     data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -16.8206   -2.6335    0.3078    2.7452    9.5974  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 4.2155751  0.0305126  138.16   <2e-16 ***
## PERROS.GSV  0.0255119  0.0005608   45.49   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.7  on 24  degrees of freedom
## Residual deviance: 1051.6  on 23  degrees of freedom
## AIC: 1225.3
## 
## Number of Fisher Scoring iterations: 4
#plots residuos
par(mfrow=c(2,2))
plot(modelo_12)

#MODELO 13
modelo_13<- glm(PERROS.ENC.TOT ~ PERROS.GSV + KILOMETROS ,
               family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_13)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV + KILOMETROS, family = poisson(link = "log"), 
##     data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -10.3720   -3.4789   -0.1846    2.6044    8.3884  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  4.346790   0.028958 150.106  < 2e-16 ***
## PERROS.GSV  -0.009272   0.001844  -5.029 4.94e-07 ***
## KILOMETROS   0.430017   0.021876  19.657  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.66  on 24  degrees of freedom
## Residual deviance:  633.17  on 22  degrees of freedom
## AIC: 808.91
## 
## Number of Fisher Scoring iterations: 4
#plots residuos
par(mfrow=c(2,2))
plot(modelo_13)

#MODELO 14
modelo_14<- glm(PERROS.ENC.TOT ~ PERROS.GSV +  offset(log(KILOMETROS)) ,
               family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_14)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -14.7109   -2.4116    0.7496    4.1812    6.9966  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 4.2592876  0.0304659 139.805  < 2e-16 ***
## PERROS.GSV  0.0025329  0.0005597   4.526 6.02e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 783.99  on 24  degrees of freedom
## Residual deviance: 763.66  on 23  degrees of freedom
## AIC: 937.4
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_14)

#MODELO 15
modelo_15<- glm(PERROS.ENC.TOT ~ PERROS.GSV +  AREA ,
               family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_15)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV + AREA, family = poisson(link = "log"), 
##     data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -16.112   -2.888    0.450    3.064    9.648  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 4.2324703  0.0307662 137.569  < 2e-16 ***
## PERROS.GSV  0.0227001  0.0011479  19.776  < 2e-16 ***
## AREA        0.0009063  0.0003252   2.787  0.00532 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.7  on 24  degrees of freedom
## Residual deviance: 1043.9  on 22  degrees of freedom
## AIC: 1219.6
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_15)

#MODELO 16
modelo_16<- glm(PERROS.ENC.TOT ~ PERROS.GSV +  offset(log(AREA)) ,
                family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_16)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV + offset(log(AREA)), 
##     family = poisson(link = "log"), data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -20.170   -6.702    3.267    7.011   11.554  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 0.6021944  0.0293403  20.524  < 2e-16 ***
## PERROS.GSV  0.0033482  0.0005327   6.285 3.27e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2106.2  on 24  degrees of freedom
## Residual deviance: 2067.0  on 23  degrees of freedom
## AIC: 2240.7
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_16)

#MODELO 17
modelo_17<- glm(PERROS.ENC.TOT ~ PERROS.GSV + KILOMETROS + AREA ,
                family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_17)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV + KILOMETROS + AREA, 
##     family = poisson(link = "log"), data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.2081  -2.8775  -0.5077   2.2540   7.0929  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  4.2430590  0.0313793 135.218  < 2e-16 ***
## PERROS.GSV  -0.0150318  0.0019652  -7.649 2.02e-14 ***
## KILOMETROS   0.9239788  0.0375018  24.638  < 2e-16 ***
## AREA        -0.0106802  0.0006315 -16.911  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.66  on 24  degrees of freedom
## Residual deviance:  287.71  on 21  degrees of freedom
## AIC: 465.45
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_17)

COMPARANDO MODELOS PARA PERROS LIBRE ACCESO ENCUESTAS Y PERROS STREET VIEW

#comparando modelo 0 y modelo 1
anova(modelo_0, modelo_1, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC ~ PERROS.GSV
## Model 2: PERROS.ENC ~ PERROS.GSV + KILOMETROS
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     232.65                          
## 2        22     207.26  1   25.392 4.677e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#comparando modelo 0 y modelo 3
anova(modelo_0, modelo_3, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC ~ PERROS.GSV
## Model 2: PERROS.ENC ~ PERROS.GSV + AREA
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     232.65                          
## 2        22     198.38  1   34.265 4.809e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#comparando modelo 0 y modelo 5
anova(modelo_0, modelo_5, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC ~ PERROS.GSV
## Model 2: PERROS.ENC ~ PERROS.GSV + KILOMETROS + AREA
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     232.65                          
## 2        21     196.17  2   36.478 1.199e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

COMPARANDO MODELOS PARA PERROS LIBRE ACCESO ENCUESTAS Y/O PERROS QUE PASEAN SIN CORREA Y PERROS STREET VIEW

#comparando modelo 6 y modelo 7
anova(modelo_6, modelo_7, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.SIN.COR ~ PERROS.GSV
## Model 2: PERROS.ENC.SIN.COR ~ PERROS.GSV + KILOMETROS
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     317.18                          
## 2        22     226.39  1   90.794 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#comparando modelo 6 y modelo 9
anova(modelo_6, modelo_9, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.SIN.COR ~ PERROS.GSV
## Model 2: PERROS.ENC.SIN.COR ~ PERROS.GSV + AREA
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     317.18                          
## 2        22     301.18  1   16.002 6.329e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#comparando modelo 6 y modelo 11
anova(modelo_6, modelo_11, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.SIN.COR ~ PERROS.GSV
## Model 2: PERROS.ENC.SIN.COR ~ PERROS.GSV + KILOMETROS + AREA
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     317.18                          
## 2        21     210.19  2   106.99 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

COMPARANDO MODELOS PARA POBLACION TOTAL PERROS ENCUESTAS Y PERROS STREET VIEW

#comparando modelo 12 y modelo 13
anova(modelo_12, modelo_13, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.TOT ~ PERROS.GSV
## Model 2: PERROS.ENC.TOT ~ PERROS.GSV + KILOMETROS
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23    1051.58                          
## 2        22     633.17  1   418.41 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#comparando modelo 12 y modelo 15
anova(modelo_12, modelo_15, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.TOT ~ PERROS.GSV
## Model 2: PERROS.ENC.TOT ~ PERROS.GSV + AREA
##   Resid. Df Resid. Dev Df Deviance Pr(>Chi)   
## 1        23     1051.6                        
## 2        22     1043.9  1   7.7072   0.0055 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#comparando modelo 12 y modelo 17
anova(modelo_12, modelo_17, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.TOT ~ PERROS.GSV
## Model 2: PERROS.ENC.TOT ~ PERROS.GSV + KILOMETROS + AREA
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23    1051.58                          
## 2        21     287.71  2   763.87 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

ANALISIS DE SENSIBILIDAD

PERROS CON ACCESO A LA CALLE ENCUESTAS

PERROS UNICOS

##PERROS UNICOS

#seleccionando perros unicos
PERROS_GSV.UNIQUE<-select(PERROS_GOOGLE, ZONA,CODIGO_PERRO)
PERROS_GSV.UNIQUE<-PERROS_GSV.UNIQUE %>%group_by(CODIGO_PERRO) %>%slice(1)

#   CREANDO DATA FRAME PERROS GSV
PERROS_GSV.UNIQUE<-select(PERROS_GSV.UNIQUE,ZONA)
PERROS_GSV.UNIQUE<-as.data.frame(table(PERROS_GSV.UNIQUE))
PERROS_GSV.UNIQUE<-filter(PERROS_GSV.UNIQUE,Freq==1)
PERROS_GSV.UNIQUE<-select(PERROS_GSV.UNIQUE,ZONA)
PERROS_GSV.UNIQUE<-as.data.frame(table(PERROS_GSV.UNIQUE))

#nombrando columnas
colnames(PERROS_GSV.UNIQUE)[1] <- "ZONA"
colnames(PERROS_GSV.UNIQUE)[2] <- "PERROS_GSV.UNIQUE"
PERROS_GSV.UNIQUE$ZONA<-as.factor(PERROS_GSV.UNIQUE$ZONA)

#merge 

PERROS_LIB.ACCE.2<-merge(ENC_PERROS_LIB.ACCE,PERROS_GSV.UNIQUE,by="ZONA")

PERROS_LIB.ACCE.2<-merge(PERROS_LIB.ACCE.2,PERROS_KM,by="ZONA")

#distribuci昼㸳n normal
hist(PERROS_LIB.ACCE.2$PERROS_GSV.UNIQUE, xlab = "PERROS.GSV", ylab = "ZONA")

#correlaci昼㸳n de spearman
cor(x=PERROS_LIB.ACCE.2$PERROS_GSV.UNIQUE,y=PERROS_LIB.ACCE.2$PERROS.ENC 
    , method = "spearman")
## [1] 0.5859016
#GRAFICAS
PERROS_FREE.UNIQUE<-ggplot(data=PERROS_LIB.ACCE.2,aes(PERROS_GSV.UNIQUE,PERROS.ENC )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="PERROS LIBRE ACCESO ENCUESTAS Y PERROS STREET VIEW - UNIQUE")+
  geom_text(data=PERROS_LIB.ACCE.2,x=75,y=20,label="??=0.6103408")

PERROS_FREE.UNIQUE

PERROS CON ACCESO A LA CALLE ENCUESTAS

PERRROS SIN REPETICIONES

#elimanando los repetidos
PERROS_GSV.SIN_REP <- as.data.frame(table(PERROS_GOOGLE$CODIGO_PERRO))
PERROS_GSV.SIN_REP <- subset(PERROS_GSV.SIN_REP, Freq < 2)
PERROS_GSV.SIN_REP$Var1 <- factor(PERROS_GSV.SIN_REP$Var1)

#Vector de perros no duplicados
VECTOR_PERROS_GSV.SIN_REP <- unique(PERROS_GSV.SIN_REP$Var1)

#creando data.frame de perros sin REP
PERROS.SIN.REP <- subset(PERROS_GOOGLE, CODIGO_PERRO %in% VECTOR_PERROS_GSV.SIN_REP)

#   CREANDO DATA FRAME PERROS GSV
PERROS.SIN.REP<-select(PERROS.SIN.REP,ZONA)
PERROS.SIN.REP<-as.data.frame(table(PERROS.SIN.REP))

colnames(PERROS.SIN.REP)[1] <- "ZONA"
colnames(PERROS.SIN.REP)[2] <- "PERROS.GSV.SIN.REP"
PERROS.SIN.REP$ZONA<-as.factor(PERROS.SIN.REP$ZONA)

#merge 

PERROS_LIB.ACCE.3<-merge(ENC_PERROS_LIB.ACCE,PERROS.SIN.REP,by="ZONA")

PERROS_LIB.ACCE.3<-merge(PERROS_LIB.ACCE.3,PERROS_KM,by="ZONA")

#distribuci昼㸳n normal
hist(PERROS_LIB.ACCE.3$PERROS.GSV.SIN.REP, xlab = "PERROS.GSV", ylab = "ZONA")

#correlaci昼㸳n de spearman
cor(x=PERROS_LIB.ACCE.3$PERROS.GSV.SIN.REP,y=PERROS_LIB.ACCE.3$PERROS.ENC 
    , method = "spearman")
## [1] 0.5548487
#GRAFICAS
PERROS_FREE.SIN.REP<-ggplot(data=PERROS_LIB.ACCE.3,aes(PERROS.GSV.SIN.REP,PERROS.ENC )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="PERROS LIBRE ACCESO ENCUESTAS Y PERROS STREET VIEW - SIN.REP")+
  geom_text(data=PERROS_LIB.ACCE.3,x=65,y=20,label="??=0.5833904")

PERROS_FREE.SIN.REP

COMPARACION DE GRAFICAS

##PLOTS

cowplot::plot_grid(PERROS_FREE,PERROS_FREE.UNIQUE,PERROS_FREE.SIN.REP, labels="AUTO")

PERROS CON ACCESO A LA CALLE O PASEAN SIN CORREA ENCUESTAS

PERROS UNICOS

#merge 
PERROS_SIN.CORREA.2<-merge(ENC_PERROS_SIN.CORREA,PERROS_GSV.UNIQUE,by="ZONA")

PERROS_SIN.CORREA.2<-merge(PERROS_SIN.CORREA.2,PERROS_KM,by="ZONA")

#distribuci昼㸳n normal
hist(PERROS_SIN.CORREA.2$PERROS_GSV.UNIQUE, xlab = "PERROS.GSV", ylab = "ZONA")

#correlaci昼㸳n de spearman
cor(x=PERROS_SIN.CORREA.2$PERROS_GSV.UNIQUE,y=PERROS_SIN.CORREA.2$PERROS.ENC.SIN.COR 
    , method = "spearman")
## [1] 0.5803657
#GRAFICAS
PERROS.SIN.CORR.UNI<-ggplot(data=PERROS_SIN.CORREA.2,aes(PERROS_GSV.UNIQUE,PERROS.ENC.SIN.COR )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="PERROS ENCUESTAS CON LIBRE ACCESO
       Y/O PASEAN SIN CORREA - UNICOS")+
  geom_text(data=PERROS_SIN.CORREA.2,x=65,y=20,label="??=0.625706")
 
PERROS.SIN.CORR.UNI 

PERRROS SIN REPETICIONES

#PERRROS SIN REPETICIONES

#merge 
PERROS_SIN.CORREA.3<-merge(ENC_PERROS_SIN.CORREA,PERROS.SIN.REP,by="ZONA")

PERROS_SIN.CORREA.3<-merge(PERROS_SIN.CORREA.3,PERROS_KM,by="ZONA")

#distribuci昼㸳n normal
hist(PERROS_SIN.CORREA.3$PERROS.GSV.SIN.REP, xlab ="PERROS.GSV", ylab = "ZONA")

#correlaci昼㸳n de spearman
cor(x=PERROS_SIN.CORREA.3$PERROS.GSV.SIN.REP,y=PERROS_SIN.CORREA.3$PERROS.ENC.SIN.COR 
    , method = "spearman")
## [1] 0.6429674
#GRAFICAS
PERROS.SIN.CORR.SIN.REP<-ggplot(data=PERROS_SIN.CORREA.3,aes(PERROS.GSV.SIN.REP,PERROS.ENC.SIN.COR )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="PERROS ENCUESTAS CON LIBRE ACCESO
       Y/O PASEAN SIN CORREA - SIN.REP")+
  geom_text(data=PERROS_SIN.CORREA.3,x=65,y=20,label="??=0.6809312")

PERROS.SIN.CORR.SIN.REP

COMPARACION DE GRAFICAS

##PLOTS

cowplot::plot_grid(PERROS.SIN.CORR,PERROS.SIN.CORR.UNI,PERROS.SIN.CORR.SIN.REP, labels="AUTO")

PERROS POBLACION TOTAL ENCUESTAS

PERROS UNICOS

#merge 

PERROS_TOTAL.2<-merge(ENC_PERROS_TOTAL,PERROS_GSV.UNIQUE,by="ZONA")

PERROS_TOTAL.2<-merge(PERROS_TOTAL.2,PERROS_KM,by="ZONA")

#distribuci昼㸳n normal
hist(PERROS_TOTAL.2$PERROS_GSV.UNIQUE, xlab ="PERROS.GSV", ylab = "ZONA")

#correlaci昼㸳n de spearman
cor(x=PERROS_TOTAL.2$PERROS_GSV.UNIQUE,y=PERROS_TOTAL.2$PERROS.ENC.TOT 
    , method = "spearman")
## [1] 0.5228016
#GRAFICAS
PERROS.TOTAL.UNI<-ggplot(data=PERROS_TOTAL.2,aes(PERROS_GSV.UNIQUE,PERROS.ENC.TOT )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="POBLACION TOTAL PERROS ENCUESTAS - UNICOS")+
  geom_text(data=PERROS_TOTAL.2,x=65,y=20,label="??=0.5752652")

PERROS.TOTAL.UNI

PERROS SIN REPETICIONES

#merge 

PERROS_TOTAL.3<-merge(ENC_PERROS_TOTAL,PERROS.SIN.REP,by="ZONA")

PERROS_TOTAL.3<-merge(PERROS_TOTAL.3,PERROS_KM,by="ZONA")

#distribuci昼㸳n normal
hist(PERROS_TOTAL.3$PERROS.GSV.SIN.REP, xlab ="PERROS.GSV", ylab = "ZONA")

#correlaci昼㸳n de spearman
cor(x=PERROS_TOTAL.3$PERROS.GSV.SIN.REP,y=PERROS_TOTAL.3$PERROS.ENC.TOT 
    , method = "spearman")
## [1] 0.6253856
#GRAFICAS
PERROS.TOTAL.SIN.REP<-ggplot(data=PERROS_TOTAL.3,aes(PERROS.GSV.SIN.REP,PERROS.ENC.TOT )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="POBLACION TOTAL PERROS ENCUESTAS - SIN REPETICIONES")+
  geom_text(data=PERROS_TOTAL.3,x=65,y=20,label="??=0.6687768")

PERROS.TOTAL.SIN.REP

COMPARACION DE GRAFICAS

#PLOTS

cowplot::plot_grid(PERROS_TOTAL,PERROS.TOTAL.UNI,PERROS.TOTAL.SIN.REP, labels="AUTO")

GRAFICAS GLM POISSON Y LM EN PERROS GSV VS PERROS ENCUESTAS

#GRAFICAS GLM POISSON

PERROS_FREE.POISSON<-ggplot(data=PERROS_LIB.ACCE.1,aes(PERROS.GSV,PERROS.ENC )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "glm",
               method.args = list(family = 'poisson'), colour="Red")+
  geom_smooth(method = "lm", colour="blue")+
  labs(x="GSV",y="ENCUESTAS", 
       title="PERROS LIBRE ACCESO ENCUESTAS Y PERROS STREET VIEW")+
  geom_text(data=PERROS_LIB.ACCE.1,x=75,y=20,label="??=0.6202706")


PERROS.SIN.CORR.POISSON<-ggplot(data=PERROS_SIN.CORREA.1,aes(PERROS.GSV,PERROS.ENC.SIN.COR )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "glm",
      method.args = list(family = 'poisson'), colour="Red")+ 
  geom_smooth(method = "lm", colour="blue")+
  labs(x="GSV",y="ENCUESTAS", 
       title="PERROS ENCUESTAS CON LIBRE ACCESO
       Y/O PASEAN SIN CORREA")+
  geom_text(data=PERROS_SIN.CORREA.1,x=75,y=20,label="??=0.6542872")


PERROS_TOTAL.POISSON<-ggplot(data=PERROS_TOTAL.1,aes(PERROS.GSV,PERROS.ENC.TOT )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "glm", 
          method.args = list(family = 'poisson'), colour="Red")+
  geom_smooth(method = "lm", colour="blue")+
  labs(x="GSV",y="ENCUESTAS", 
       title="POBLACION TOTAL PERROS ENCUESTAS")+
  geom_text(data=PERROS_TOTAL.1,x=75,y=20,label="??=0.5412248")


#PLOTS

plot_grid(PERROS_FREE.POISSON,PERROS.SIN.CORR.POISSON,PERROS_TOTAL.POISSON, labels="AUTO")

MODELOS POISSON PERROS LIBRE ACCESO ENCUESTAS Y PERROS STREET VIEW UNICOS

modelo_0<- glm(PERROS.ENC ~ PERROS_GSV.UNIQUE,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.2)

summary(modelo_0)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS_GSV.UNIQUE, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.9739  -2.5482   0.0722   1.9246   6.0559  
## 
## Coefficients:
##                   Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       2.831113   0.063732   44.42   <2e-16 ***
## PERROS_GSV.UNIQUE 0.021204   0.001301   16.30   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 231.88  on 23  degrees of freedom
## AIC: 363.9
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_0)

#MODELO 1
modelo_1<- glm(PERROS.ENC ~ PERROS_GSV.UNIQUE + KILOMETROS ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.2)

summary(modelo_1)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS_GSV.UNIQUE + KILOMETROS, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.8628  -2.4096  -0.4601   1.3980   6.0000  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       2.8413372  0.0611666  46.452  < 2e-16 ***
## PERROS_GSV.UNIQUE 0.0004493  0.0044459   0.101    0.919    
## KILOMETROS        0.2600525  0.0536242   4.850 1.24e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 207.68  on 22  degrees of freedom
## AIC: 341.7
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_1)

#MODELO 2
modelo_2<- glm(PERROS.ENC ~ PERROS_GSV.UNIQUE +  offset(log(KILOMETROS)) ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.2)

summary(modelo_2)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS_GSV.UNIQUE + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_LIB.ACCE.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.0960  -1.4267  -0.8255   1.3783   6.2251  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        2.811283   0.063939  43.968   <2e-16 ***
## PERROS_GSV.UNIQUE -0.002014   0.001307  -1.541    0.123    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 211.34  on 24  degrees of freedom
## Residual deviance: 208.94  on 23  degrees of freedom
## AIC: 340.96
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_2)

#MODELO 3
modelo_3<- glm(PERROS.ENC ~ PERROS_GSV.UNIQUE +  AREA ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.2)

summary(modelo_3)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS_GSV.UNIQUE + AREA, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.4230  -2.7857  -0.2824   1.8770   6.2925  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       2.8228666  0.0614953  45.904  < 2e-16 ***
## PERROS_GSV.UNIQUE 0.0091084  0.0022788   3.997 6.41e-05 ***
## AREA              0.0041330  0.0006746   6.127 8.98e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 196.11  on 22  degrees of freedom
## AIC: 330.12
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_3)

#MODELO 4
modelo_4<- glm(PERROS.ENC ~ PERROS_GSV.UNIQUE +  offset(log(AREA)) ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.2)

summary(modelo_4)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS_GSV.UNIQUE + offset(log(AREA)), 
##     family = poisson(link = "log"), data = PERROS_LIB.ACCE.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.8705  -2.1403   0.7838   1.5518   6.4822  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       -0.9015394  0.0605831 -14.881   <2e-16 ***
## PERROS_GSV.UNIQUE  0.0001744  0.0012116   0.144    0.886    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 218.96  on 24  degrees of freedom
## Residual deviance: 218.94  on 23  degrees of freedom
## AIC: 350.96
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_4)

#MODELO 5
modelo_5<- glm(PERROS.ENC ~ PERROS_GSV.UNIQUE + KILOMETROS + AREA ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.2)

summary(modelo_5)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS_GSV.UNIQUE + KILOMETROS + AREA, 
##     family = poisson(link = "log"), data = PERROS_LIB.ACCE.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.4683  -2.8141  -0.3344   1.8538   6.2492  
## 
## Coefficients:
##                   Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       2.826864   0.061482  45.979  < 2e-16 ***
## PERROS_GSV.UNIQUE 0.006206   0.004745   1.308 0.190940    
## KILOMETROS        0.055321   0.079243   0.698 0.485101    
## AREA              0.003609   0.001013   3.561 0.000369 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 195.62  on 21  degrees of freedom
## AIC: 331.64
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_5)

MODELOS POISSON PERROS LIBRE ACCESO ENCUESTAS Y/O PERROS QUE PASEAN SIN CORREA

Y PERROS STREET VIEW UNICOS

#MODELO 6
modelo_6<- glm(PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)

summary(modelo_6)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE, family = poisson(link = "log"), 
##     data = PERROS_SIN.CORREA.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.4860  -2.4901  -0.7828   3.1374   5.8246  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       3.3695279  0.0460381   73.19   <2e-16 ***
## PERROS_GSV.UNIQUE 0.0252292  0.0008926   28.27   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  287.81  on 23  degrees of freedom
## AIC: 438.68
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_6)

#MODELO 7
modelo_7<- glm(PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE + KILOMETROS ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)

summary(modelo_7)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE + KILOMETROS, 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -4.880  -2.457  -1.204   2.050   5.687  
## 
## Coefficients:
##                   Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       3.399411   0.044031  77.205  < 2e-16 ***
## PERROS_GSV.UNIQUE 0.001331   0.003196   0.416    0.677    
## KILOMETROS        0.293537   0.038058   7.713 1.23e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  226.24  on 22  degrees of freedom
## AIC: 379.11
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_7)

#MODELO 8
modelo_8<- glm(PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE +  offset(log(KILOMETROS)) ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)

summary(modelo_8)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.3979  -1.7360  -0.8797   2.3457   8.3094  
## 
## Coefficients:
##                   Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       3.348470   0.046130  72.587   <2e-16 ***
## PERROS_GSV.UNIQUE 0.002040   0.000895   2.279   0.0227 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 250.08  on 24  degrees of freedom
## Residual deviance: 244.92  on 23  degrees of freedom
## AIC: 395.79
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_8)

#MODELO 9
modelo_9<- glm(PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE +  AREA ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)

summary(modelo_9)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE + AREA, 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.9136  -1.9455  -0.8735   2.3884   5.8789  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       3.3823031  0.0452745  74.707  < 2e-16 ***
## PERROS_GSV.UNIQUE 0.0198086  0.0017672  11.209  < 2e-16 ***
## AREA              0.0017596  0.0005048   3.486  0.00049 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.5  on 24  degrees of freedom
## Residual deviance:  275.9  on 22  degrees of freedom
## AIC: 428.77
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_9)

#MODELO 10
modelo_10<- glm(PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE +  offset(log(AREA)) ,
                family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)

summary(modelo_10)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE + offset(log(AREA)), 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -10.1504   -2.2284    0.8606    2.4174    7.9401  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       -0.3408717  0.0438668  -7.771 7.81e-15 ***
## PERROS_GSV.UNIQUE  0.0036827  0.0008354   4.408 1.04e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 530.10  on 24  degrees of freedom
## Residual deviance: 510.86  on 23  degrees of freedom
## AIC: 661.73
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_10)

#MODELO 11
modelo_11<- glm(PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE + KILOMETROS + AREA ,
                family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)

summary(modelo_11)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE + KILOMETROS + 
##     AREA, family = poisson(link = "log"), data = PERROS_SIN.CORREA.2)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -4.896  -2.366  -1.097   2.438   5.513  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        3.3880997  0.0445071  76.125  < 2e-16 ***
## PERROS_GSV.UNIQUE -0.0031774  0.0033860  -0.938    0.348    
## KILOMETROS         0.4790208  0.0600836   7.973 1.55e-15 ***
## AREA              -0.0033971  0.0008605  -3.948 7.88e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  209.79  on 21  degrees of freedom
## AIC: 364.65
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_11)

MODELOS POISSON POBLACION TOTAL PERROS ENCUESTAS Y PERROS STREET VIEW UNICOS

#MODELO 12
modelo_12<- glm(PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE,
                family = poisson(link = "log"), data = PERROS_TOTAL.2)

summary(modelo_12)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE, family = poisson(link = "log"), 
##     data = PERROS_TOTAL.2)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -14.7906   -2.7768    0.0531    2.5262    9.4613  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       4.2538610  0.0290700  146.33   <2e-16 ***
## PERROS_GSV.UNIQUE 0.0264789  0.0005549   47.72   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.66  on 24  degrees of freedom
## Residual deviance:  872.74  on 23  degrees of freedom
## AIC: 1046.5
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_12)

#MODELO 13
modelo_13<- glm(PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE + KILOMETROS ,
                family = poisson(link = "log"), data = PERROS_TOTAL.2)

summary(modelo_13)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE + KILOMETROS, 
##     family = poisson(link = "log"), data = PERROS_TOTAL.2)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -11.4617   -3.1356    0.4129    2.8543    8.0954  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        4.291884   0.027616 155.414   <2e-16 ***
## PERROS_GSV.UNIQUE -0.001810   0.002026  -0.893    0.372    
## KILOMETROS         0.345742   0.024104  14.344   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.66  on 24  degrees of freedom
## Residual deviance:  658.04  on 22  degrees of freedom
## AIC: 833.77
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_13)

#MODELO 14
modelo_14<- glm(PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE +  offset(log(KILOMETROS)) ,
                family = poisson(link = "log"), data = PERROS_TOTAL.2)

summary(modelo_14)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_TOTAL.2)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -14.5244   -2.4610    0.8018    3.8143    7.3195  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       4.2325280  0.0291183 145.356  < 2e-16 ***
## PERROS_GSV.UNIQUE 0.0032956  0.0005561   5.926  3.1e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 783.99  on 24  degrees of freedom
## Residual deviance: 749.22  on 23  degrees of freedom
## AIC: 922.95
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_14)

#MODELO 15
modelo_15<- glm(PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE +  AREA ,
                family = poisson(link = "log"), data = PERROS_TOTAL.2)

summary(modelo_15)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE + AREA, family = poisson(link = "log"), 
##     data = PERROS_TOTAL.2)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -14.8016   -2.7613    0.0469    2.5331    9.4596  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        4.254e+00  2.935e-02  144.93   <2e-16 ***
## PERROS_GSV.UNIQUE  2.655e-02  1.172e-03   22.65   <2e-16 ***
## AREA              -2.296e-05  3.278e-04   -0.07    0.944    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.66  on 24  degrees of freedom
## Residual deviance:  872.74  on 22  degrees of freedom
## AIC: 1048.5
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_15)

#MODELO 16
modelo_16<- glm(PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE +  offset(log(AREA)) ,
                family = poisson(link = "log"), data = PERROS_TOTAL.2)

summary(modelo_16)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE + offset(log(AREA)), 
##     family = poisson(link = "log"), data = PERROS_TOTAL.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -18.973   -6.682    3.842    7.028   12.019  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       0.5503427  0.0277193  19.854   <2e-16 ***
## PERROS_GSV.UNIQUE 0.0047792  0.0005201   9.189   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2106.2  on 24  degrees of freedom
## Residual deviance: 2022.7  on 23  degrees of freedom
## AIC: 2196.5
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_16)

#MODELO 17
modelo_17<- glm(PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE + KILOMETROS + AREA ,
                family = poisson(link = "log"), data = PERROS_TOTAL.2)

summary(modelo_17)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE + KILOMETROS + 
##     AREA, family = poisson(link = "log"), data = PERROS_TOTAL.2)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.7941  -2.6699   0.0672   2.3363   7.6761  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        4.1862211  0.0299747 139.658  < 2e-16 ***
## PERROS_GSV.UNIQUE -0.0147085  0.0021422  -6.866  6.6e-12 ***
## KILOMETROS         0.9446547  0.0416472  22.682  < 2e-16 ***
## AREA              -0.0112326  0.0006508 -17.258  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.66  on 24  degrees of freedom
## Residual deviance:  300.57  on 21  degrees of freedom
## AIC: 478.3
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_17)

COMPARANDO MODELOS PARA PERROS LIBRE ACCESO ENCUESTAS Y PERROS STREET VIEW

UNICOS

#comparando modelo 0 y modelo 1
anova(modelo_0, modelo_4, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC ~ PERROS_GSV.UNIQUE
## Model 2: PERROS.ENC ~ PERROS_GSV.UNIQUE + offset(log(AREA))
##   Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1        23     231.88                     
## 2        23     218.94  0    12.94
#comparando modelo 0 y modelo 3
anova(modelo_0, modelo_3, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC ~ PERROS_GSV.UNIQUE
## Model 2: PERROS.ENC ~ PERROS_GSV.UNIQUE + AREA
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     231.88                          
## 2        22     196.11  1   35.772 2.218e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#comparando modelo 0 y modelo 5
anova(modelo_0, modelo_5, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC ~ PERROS_GSV.UNIQUE
## Model 2: PERROS.ENC ~ PERROS_GSV.UNIQUE + KILOMETROS + AREA
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     231.88                          
## 2        21     195.62  2   36.261 1.337e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

COMPARANDO MODELOS PARA PERROS LIBRE ACCESO ENCUESTAS Y/O PERROS QUE PASEAN SIN CORREA Y PERROS STREET VIEW UNICOS

#comparando modelo 6 y modelo 7
anova(modelo_6, modelo_7, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE
## Model 2: PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE + KILOMETROS
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     287.81                          
## 2        22     226.24  1   61.574 4.264e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#comparando modelo 6 y modelo 9
anova(modelo_6, modelo_9, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE
## Model 2: PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE + AREA
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     287.81                          
## 2        22     275.90  1   11.911 0.0005581 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#comparando modelo 6 y modelo 11
anova(modelo_6, modelo_11, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE
## Model 2: PERROS.ENC.SIN.COR ~ PERROS_GSV.UNIQUE + KILOMETROS + AREA
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     287.81                          
## 2        21     209.78  2    78.03 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

COMPARANDO MODELOS PARA POBLACION TOTAL PERROS ENCUESTAS Y PERROS STREET VIEW UNICOS

#comparando modelo 12 y modelo 13
anova(modelo_12, modelo_13, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE
## Model 2: PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE + KILOMETROS
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     872.74                          
## 2        22     658.04  1    214.7 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#comparando modelo 12 y modelo 15
anova(modelo_12, modelo_15, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE
## Model 2: PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE + AREA
##   Resid. Df Resid. Dev Df  Deviance Pr(>Chi)
## 1        23     872.74                      
## 2        22     872.74  1 0.0049062   0.9442
#comparando modelo 12 y modelo 17
anova(modelo_12, modelo_17, test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE
## Model 2: PERROS.ENC.TOT ~ PERROS_GSV.UNIQUE + KILOMETROS + AREA
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1        23     872.74                          
## 2        21     300.57  2   572.17 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

MODELOS POISSON POBLACION TOTAL PERROS ENCUESTAS Y PERROS STREET VIEW SIN REPETICIONES

modelo_0<- glm(PERROS.ENC ~ PERROS.GSV.SIN.REP,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.3)

summary(modelo_0)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV.SIN.REP, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.6435  -2.0049   0.0271   2.0723   6.1272  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        2.871002   0.063651   45.10   <2e-16 ***
## PERROS.GSV.SIN.REP 0.022804   0.001483   15.38   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 252.84  on 23  degrees of freedom
## AIC: 384.86
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_0)

#MODELO 1
modelo_1<- glm(PERROS.ENC ~ PERROS.GSV.SIN.REP + KILOMETROS ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.3)

summary(modelo_1)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV.SIN.REP + KILOMETROS, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.8394  -2.6390  -0.1552   1.6105   5.9441  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         2.854460   0.060450  47.220  < 2e-16 ***
## PERROS.GSV.SIN.REP -0.004316   0.004296  -1.005    0.315    
## KILOMETROS          0.309083   0.046119   6.702 2.06e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 206.68  on 22  degrees of freedom
## AIC: 340.7
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_1)

#MODELO 2
modelo_2<- glm(PERROS.ENC ~ PERROS.GSV.SIN.REP +  offset(log(KILOMETROS)) ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.3)

summary(modelo_2)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV.SIN.REP + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_LIB.ACCE.3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.9875  -1.5061  -0.8869   1.2779   6.1422  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         2.840871   0.063129  45.001   <2e-16 ***
## PERROS.GSV.SIN.REP -0.003078   0.001466  -2.099   0.0358 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 211.34  on 24  degrees of freedom
## Residual deviance: 206.90  on 23  degrees of freedom
## AIC: 338.91
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_2)

#MODELO 3
modelo_3<- glm(PERROS.ENC ~ PERROS.GSV.SIN.REP +  AREA ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.3)

summary(modelo_3)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV.SIN.REP + AREA, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.4003  -2.9229  -0.1884   1.7816   6.3521  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        2.8342276  0.0613124  46.226  < 2e-16 ***
## PERROS.GSV.SIN.REP 0.0083308  0.0023511   3.543 0.000395 ***
## AREA               0.0046151  0.0006223   7.416  1.2e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 199.97  on 22  degrees of freedom
## AIC: 333.98
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_3)

#MODELO 4
modelo_4<- glm(PERROS.ENC ~ PERROS.GSV.SIN.REP +  offset(log(AREA)) ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.3)

summary(modelo_4)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV.SIN.REP + offset(log(AREA)), 
##     family = poisson(link = "log"), data = PERROS_LIB.ACCE.3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.8936  -2.1325   0.7701   1.5466   6.4734  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        -8.977e-01  5.963e-02  -15.05   <2e-16 ***
## PERROS.GSV.SIN.REP  9.531e-05  1.352e-03    0.07    0.944    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 218.96  on 24  degrees of freedom
## Residual deviance: 218.96  on 23  degrees of freedom
## AIC: 350.97
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_4)

#MODELO 5
modelo_5<- glm(PERROS.ENC ~ PERROS.GSV.SIN.REP + KILOMETROS + AREA ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.3)

summary(modelo_5)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV.SIN.REP + KILOMETROS + 
##     AREA, family = poisson(link = "log"), data = PERROS_LIB.ACCE.3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.4993  -2.9687  -0.1515   1.8564   6.2093  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        2.840483   0.060821  46.703  < 2e-16 ***
## PERROS.GSV.SIN.REP 0.001629   0.004688   0.348  0.72818    
## KILOMETROS         0.123605   0.074837   1.652  0.09861 .  
## AREA               0.003273   0.001036   3.160  0.00158 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 471.14  on 24  degrees of freedom
## Residual deviance: 197.20  on 21  degrees of freedom
## AIC: 333.22
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_5)

MODELOS POISSON PERROS LIBRE ACCESO ENCUESTAS Y/O PERROS QUE PASEAN SIN CORREA

Y PERROS STREET VIEW UNICOS SIN REPETICIONES

#MODELO 6
modelo_6<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)

summary(modelo_6)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP, family = poisson(link = "log"), 
##     data = PERROS_SIN.CORREA.3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.4780  -2.2761  -0.4352   2.2108   6.0939  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        3.372454   0.046541   72.46   <2e-16 ***
## PERROS.GSV.SIN.REP 0.028344   0.001021   27.75   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  293.06  on 23  degrees of freedom
## AIC: 443.93
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_6)

#MODELO 7
modelo_7<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP + KILOMETROS ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)

summary(modelo_7)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP + KILOMETROS, 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -4.835  -2.220  -1.113   2.522   5.768  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        3.387267   0.044332  76.407  < 2e-16 ***
## PERROS.GSV.SIN.REP 0.004671   0.003043   1.535    0.125    
## KILOMETROS         0.262147   0.031962   8.202 2.37e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  224.06  on 22  degrees of freedom
## AIC: 376.93
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_7)

#MODELO 8
modelo_8<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP +  offset(log(KILOMETROS)) ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)

summary(modelo_8)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.5197  -1.7561  -0.8868   2.2512   8.3011  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        3.347366   0.046099   72.61   <2e-16 ***
## PERROS.GSV.SIN.REP 0.002330   0.001008    2.31   0.0209 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 250.08  on 24  degrees of freedom
## Residual deviance: 244.77  on 23  degrees of freedom
## AIC: 395.64
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_8)

#MODELO 9
modelo_9<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP +  AREA ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)

summary(modelo_9)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP + AREA, 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -6.780  -2.634  -0.581   3.110   6.114  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        3.3792487  0.0453513  74.513  < 2e-16 ***
## PERROS.GSV.SIN.REP 0.0209264  0.0018058  11.588  < 2e-16 ***
## AREA               0.0022191  0.0004577   4.848 1.25e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  269.94  on 22  degrees of freedom
## AIC: 422.81
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_9)

#MODELO 10
modelo_10<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP +  offset(log(AREA)) ,
                family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)

summary(modelo_10)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP + offset(log(AREA)), 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -10.0328   -1.9559    0.9089    2.4369    8.0047  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        -0.3618320  0.0436805  -8.284  < 2e-16 ***
## PERROS.GSV.SIN.REP  0.0047274  0.0009366   5.047 4.48e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 530.10  on 24  degrees of freedom
## Residual deviance: 504.78  on 23  degrees of freedom
## AIC: 655.65
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_10)

#MODELO 11
modelo_11<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP + KILOMETROS + AREA ,
                family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)

summary(modelo_11)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV.SIN.REP + KILOMETROS + 
##     AREA, family = poisson(link = "log"), data = PERROS_SIN.CORREA.3)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -4.853  -2.379  -1.123   2.511   5.545  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         3.3804394  0.0446393  75.728  < 2e-16 ***
## PERROS.GSV.SIN.REP -0.0003635  0.0033537  -0.108 0.913700    
## KILOMETROS          0.4377261  0.0585748   7.473 7.84e-14 ***
## AREA               -0.0031834  0.0008931  -3.564 0.000365 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1005.51  on 24  degrees of freedom
## Residual deviance:  210.66  on 21  degrees of freedom
## AIC: 365.52
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_11)

MODELOS POISSON POBLACION TOTAL PERROS ENCUESTAS Y PERROS STREET VIEW SIN REPETICIONES

#MODELO 12
modelo_12<- glm(PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP,
                family = poisson(link = "log"), data = PERROS_TOTAL.3)

summary(modelo_12)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP, family = poisson(link = "log"), 
##     data = PERROS_TOTAL.3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -14.7648   -3.4612    0.5218    2.3002    9.5801  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        4.2538488  0.0294470  144.46   <2e-16 ***
## PERROS.GSV.SIN.REP 0.0298270  0.0006364   46.87   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.66  on 24  degrees of freedom
## Residual deviance:  882.61  on 23  degrees of freedom
## AIC: 1056.3
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_12)

#MODELO 13
modelo_13<- glm(PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP + KILOMETROS ,
                family = poisson(link = "log"), data = PERROS_TOTAL.3)

summary(modelo_13)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP + KILOMETROS, 
##     family = poisson(link = "log"), data = PERROS_TOTAL.3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -11.8613   -3.0170    0.1139    3.1112    8.0789  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        4.276031   0.027884 153.348   <2e-16 ***
## PERROS.GSV.SIN.REP 0.002768   0.001921   1.441     0.15    
## KILOMETROS         0.297351   0.020097  14.796   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.66  on 24  degrees of freedom
## Residual deviance:  656.76  on 22  degrees of freedom
## AIC: 832.5
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_13)

#MODELO 14
modelo_14<- glm(PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP +  offset(log(KILOMETROS)) ,
                family = poisson(link = "log"), data = PERROS_TOTAL.3)

summary(modelo_14)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_TOTAL.3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -14.8236   -2.4371    0.5057    3.8417    7.2696  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        4.2302673  0.0291589  145.08  < 2e-16 ***
## PERROS.GSV.SIN.REP 0.0037748  0.0006281    6.01 1.86e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 783.99  on 24  degrees of freedom
## Residual deviance: 748.08  on 23  degrees of freedom
## AIC: 921.82
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_14)

#MODELO 15
modelo_15<- glm(PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP +  AREA ,
                family = poisson(link = "log"), data = PERROS_TOTAL.3)

summary(modelo_15)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP + AREA, family = poisson(link = "log"), 
##     data = PERROS_TOTAL.3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -14.9444   -2.9117    0.4283    2.4717    9.6455  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        4.2599433  0.0292211 145.783  < 2e-16 ***
## PERROS.GSV.SIN.REP 0.0270932  0.0011748  23.062  < 2e-16 ***
## AREA               0.0008013  0.0002920   2.744  0.00608 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.66  on 24  degrees of freedom
## Residual deviance:  875.12  on 22  degrees of freedom
## AIC: 1050.9
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_15)

#MODELO 16
modelo_16<- glm(PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP +  offset(log(AREA)) ,
                family = poisson(link = "log"), data = PERROS_TOTAL.3)

summary(modelo_16)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP + offset(log(AREA)), 
##     family = poisson(link = "log"), data = PERROS_TOTAL.3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -18.980   -6.440    3.910    6.587   12.044  
## 
## Coefficients:
##                     Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        0.5288891  0.0276509   19.13   <2e-16 ***
## PERROS.GSV.SIN.REP 0.0059761  0.0005844   10.23   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2106.2  on 24  degrees of freedom
## Residual deviance: 2002.3  on 23  degrees of freedom
## AIC: 2176
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_16)

#MODELO 17
modelo_17<- glm(PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP + KILOMETROS + AREA ,
                family = poisson(link = "log"), data = PERROS_TOTAL.3)

summary(modelo_17)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV.SIN.REP + KILOMETROS + 
##     AREA, family = poisson(link = "log"), data = PERROS_TOTAL.3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.0502  -2.5781  -0.3486   2.3127   7.4460  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         4.1806227  0.0299969 139.368  < 2e-16 ***
## PERROS.GSV.SIN.REP -0.0141768  0.0021551  -6.578 4.76e-11 ***
## KILOMETROS          0.9398706  0.0424360  22.148  < 2e-16 ***
## AREA               -0.0117992  0.0006925 -17.039  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 2919.66  on 24  degrees of freedom
## Residual deviance:  304.22  on 21  degrees of freedom
## AIC: 481.95
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_17)

ELIMINACION DE OUTLIERS

CORRELACION ENTRE PERROS ENCUESTAS Y PERROS STREET VIEW

PERROS CON ACCESO A LA CALLE ENCUESTAS

#CARGANDO BASES DE DATOS
ENCUESTA.PERROS<- read_excel("F:/BUSQUEDA PERROS/BUSQUEDA-DE-PERROS/ENCUESTA PERROS.xlsx") 
PERROS_GOOGLE<- read_excel("F:/BUSQUEDA PERROS/BUSQUEDA-DE-PERROS/DATOS PERROS.xlsx", 
                           sheet = "GOLD_STANDARD")

PRUEBA_PERROS<- read_excel("F:/BUSQUEDA PERROS/BUSQUEDA-DE-PERROS/DATOS PERROS.xlsx", 
                           sheet = "KM")

#filtrar perros deambulantes encuestas
ENC_PERROS_LIB.ACCE<-filter(ENCUESTA.PERROS,ACCESO_CALLE=="SI")

#filtrar perros GSV
PERROS_GSV<-filter(PERROS_GOOGLE,BUSQUEDA=="GS")
PERROS_GSV<-filter(PERROS_GSV, ZONA=="CONQUISTADOR II"|
                     ZONA=="A.A.H.H. JAVIER HERAUD PAMPAS POLANCO" |
                     ZONA=="VILLA FLORIDA"|ZONA=="VILLA SALVADOR"|
                     ZONA=="EL MIRADOR P. POLANCO"|ZONA=="AA. HH. PRIMERO DE ENERO"|
                     ZONA=="ANTONIO JOSE DE SUCRE"|ZONA=="AMPLIACION VILLA UNION"|
                     ZONA=="ASOC. ARTESANAL EL MISTI"|
                     ZONA=="ASOCIACION VILLA VITARTE Y SAN HILARION"|
                     ZONA=="AVIS JUAN VELASCO ALVARADO A"|ZONA=="COOP. CRUCE CHILINA"|
                     ZONA=="CONQUISTADOR II"|ZONA=="COOP. DE VIV. ENATRU"|
                     ZONA=="COOP. DE VIV. LOS EUCALIPTOS"|
                     ZONA=="HABITACION URBANA PROGRESIVA SE搼㸱OR DE LOS PIEDADES"|
                     ZONA=="PAMPA CHICA"|ZONA=="UPIS SAN LUIS"|
                     ZONA=="VILLA CONFRATERNIDAD B-II"|
                     ZONA=="VILLA CONFRATERNIDAD ZONA B III MARGEN DERECHO"|
                     ZONA=="VILLA ECOLOGICA ZONA D-1"|ZONA=="VILLA ECOLOGICA ZONA D-2 MARGEN DERECHO"|
                     ZONA=="VILLAS CHACHAS")

#filtrar zonas por km y area

PERROS_KM<-filter(PRUEBA_PERROS, ZONA=="CONQUISTADOR II"|
                     ZONA=="A.A.H.H. JAVIER HERAUD PAMPAS POLANCO" |
                     ZONA=="VILLA FLORIDA"|ZONA=="VILLA SALVADOR"|
                     ZONA=="EL MIRADOR P. POLANCO"|ZONA=="AA. HH. PRIMERO DE ENERO"|
                     ZONA=="ANTONIO JOSE DE SUCRE"|ZONA=="AMPLIACION VILLA UNION"|
                     ZONA=="ASOC. ARTESANAL EL MISTI"|
                     ZONA=="ASOCIACION VILLA VITARTE Y SAN HILARION"|
                     ZONA=="AVIS JUAN VELASCO ALVARADO A"|ZONA=="COOP. CRUCE CHILINA"|
                     ZONA=="CONQUISTADOR II"|ZONA=="COOP. DE VIV. ENATRU"|
                     ZONA=="COOP. DE VIV. LOS EUCALIPTOS"|
                     ZONA=="HABITACION URBANA PROGRESIVA SE搼㸱OR DE LOS PIEDADES"|
                     ZONA=="PAMPA CHICA"|ZONA=="UPIS SAN LUIS"|
                     ZONA=="VILLA CONFRATERNIDAD B-II"|
                     ZONA=="VILLA CONFRATERNIDAD ZONA B III MARGEN DERECHO"|
                     ZONA=="VILLA ECOLOGICA ZONA D-1"|ZONA=="VILLA ECOLOGICA ZONA D-2 MARGEN DERECHO"|
                     ZONA=="VILLAS CHACHAS")

#creando data.frame de KM Y AREA
PERROS_KM<-select(PERROS_KM,ZONA,AREA, KILOMETROS)

#creando data.frame de perros encuesta zona /perro
ENC_PERROS_LIB.ACCE<-select(ENC_PERROS_LIB.ACCE,ZONA)

ENC_PERROS_LIB.ACCE$ZONA<-as.factor(ENC_PERROS_LIB.ACCE$ZONA)
ENC_PERROS_LIB.ACCE<-as.data.frame(table(ENC_PERROS_LIB.ACCE))

colnames(ENC_PERROS_LIB.ACCE)[1] <- "ZONA"
colnames(ENC_PERROS_LIB.ACCE)[2] <- "PERROS.ENC"
ENC_PERROS_LIB.ACCE$ZONA<-as.factor(ENC_PERROS_LIB.ACCE$ZONA)

#   CREANDO DATA FRAME PERROS GSV
PERROS_GSV<-select(PERROS_GSV,ZONA)
PERROS_GSV<-as.data.frame(table(PERROS_GSV))

colnames(PERROS_GSV)[1] <- "ZONA"
colnames(PERROS_GSV)[2] <- "PERROS.GSV"
PERROS_GSV$ZONA<-as.factor(PERROS_GSV$ZONA)

#merge 

PERROS_LIB.ACCE.1<-merge(ENC_PERROS_LIB.ACCE,PERROS_GSV,by="ZONA")

PERROS_LIB.ACCE.1<-merge(PERROS_LIB.ACCE.1,PERROS_KM,by="ZONA")

#distribucion normal
par(mfrow=c(1,2))
hist(PERROS_LIB.ACCE.1$PERROS.GSV, xlab = "PERROS.GSV", ylab = "ZONAS")
hist(PERROS_LIB.ACCE.1$PERROS.ENC, xlab = "PERROS.ENC", ylab = "ZONAS")

#correlaci昼㸳n de Spearman
cor(x=PERROS_LIB.ACCE.1$PERROS.GSV,y=PERROS_LIB.ACCE.1$PERROS.ENC 
    , method = "spearman")
## [1] 0.4789973
#GRAFICAS
PERROS_FREE<-ggplot(data=PERROS_LIB.ACCE.1,aes(PERROS.GSV,PERROS.ENC )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="PERROS LIBRE ACCESO ENCUESTAS Y PERROS STREET VIEW")+
        geom_text(data=PERROS_LIB.ACCE.1,x=75,y=20,label="??=0.6202706")

PERROS_FREE

PERROS CON ACCESO A LA CALLE O PASEAN SIN CORREA ENCUESTAS

ENC_PERROS_SIN.CORREA<-filter(ENCUESTA.PERROS,ACCESO_CALLE=="SI"|PASEAN=="SI"& CORREA=="NO")

#crenado data.frame de perros encuesta sin correa y libre acceso zona /perro
ENC_PERROS_SIN.CORREA<-select(ENC_PERROS_SIN.CORREA,ZONA)

ENC_PERROS_SIN.CORREA$ZONA<-as.factor( ENC_PERROS_SIN.CORREA$ZONA)
ENC_PERROS_SIN.CORREA<-as.data.frame(table(ENC_PERROS_SIN.CORREA))

colnames(ENC_PERROS_SIN.CORREA)[1] <- "ZONA"
colnames(ENC_PERROS_SIN.CORREA)[2] <- "PERROS.ENC.SIN.COR"
ENC_PERROS_SIN.CORREA$ZONA<-as.factor(ENC_PERROS_SIN.CORREA$ZONA)

#merge 

PERROS_SIN.CORREA.1<-merge(ENC_PERROS_SIN.CORREA,PERROS_GSV,by="ZONA")

PERROS_SIN.CORREA.1<-merge(PERROS_SIN.CORREA.1,PERROS_KM,by="ZONA")

#distribucion normal
hist(PERROS_SIN.CORREA.1$PERROS.ENC , xlab = "PERROS.ENC.SIN.COR", ylab = "ZONAS")

#correlaci昼㸳n de spearman
cor(x=PERROS_SIN.CORREA.1$PERROS.GSV,y=PERROS_SIN.CORREA.1$PERROS.ENC.SIN.COR 
    , method = "spearman")
## [1] 0.562134
#GRAFICAS
PERROS.SIN.CORR<-ggplot(data=PERROS_SIN.CORREA.1,aes(PERROS.GSV,PERROS.ENC.SIN.COR )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="PERROS ENCUESTAS CON LIBRE ACCESO
       Y/O PASEAN SIN CORREA")+
  geom_text(data=PERROS_SIN.CORREA.1,x=75,y=20,label="??=0.6542872")

PERROS.SIN.CORR

PERROS POBLACION TOTAL ENCUESTAS

#creando data.frame de perros totales encuesta zona /perro
ENC_PERROS_TOTAL<-select(ENCUESTA.PERROS,ZONA)

ENC_PERROS_TOTAL$ZONA<-as.factor( ENC_PERROS_TOTAL$ZONA)
ENC_PERROS_TOTAL<-as.data.frame(table(ENC_PERROS_TOTAL))

colnames(ENC_PERROS_TOTAL)[1] <- "ZONA"
colnames(ENC_PERROS_TOTAL)[2] <- "PERROS.ENC.TOT"
ENC_PERROS_TOTAL$ZONA<-as.factor(ENC_PERROS_TOTAL$ZONA)

#merge

PERROS_TOTAL.1<-merge(ENC_PERROS_TOTAL,PERROS_GSV,by="ZONA")

PERROS_TOTAL.1<-merge(PERROS_TOTAL.1,PERROS_KM,by="ZONA")

#distribuci昼㸳n normal
hist(PERROS_TOTAL.1$PERROS.ENC.TOT, xlab = "PERROS.ENC.TOT", ylab = "ZONAS")

#correlaci昼㸳n de spearman
cor(x=PERROS_TOTAL.1$PERROS.GSV,y=PERROS_TOTAL.1$PERROS.ENC 
    , method = "spearman")
## [1] 0.5273083
#GRAFICAS
PERROS_TOTAL<-ggplot(data=PERROS_TOTAL.1,aes(PERROS.GSV,PERROS.ENC.TOT )) +
  geom_point(aes(size=0.1,alpha=0.2)) + geom_smooth(method = "lm", colour="Red")+
  labs(x="GSV",y="ENCUESTAS", 
       title="POBLACION TOTAL PERROS ENCUESTAS")+
  geom_text(data=PERROS_TOTAL.1,x=75,y=20,label="??=0.5412248")

PERROS_TOTAL

MODELOS PARA PERROS LIBRE ACCESO ENCUESTAS Y PERROS STREET VIEW

#MODELO 0
modelo_0<- glm(PERROS.ENC ~ PERROS.GSV,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_0)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.6990  -3.0350  -0.4081   1.6791   6.4451  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 2.854525   0.094148  30.320  < 2e-16 ***
## PERROS.GSV  0.017776   0.002758   6.446 1.15e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 252.84  on 20  degrees of freedom
## Residual deviance: 212.01  on 19  degrees of freedom
## AIC: 320.07
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_0)

#MODELO 1
modelo_1<- glm(PERROS.ENC ~ PERROS.GSV + KILOMETROS ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_1)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV + KILOMETROS, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.6187  -3.0775  -0.8105   1.0515   6.0313  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  2.562077   0.117230  21.855  < 2e-16 ***
## PERROS.GSV  -0.003176   0.005471  -0.580    0.562    
## KILOMETROS   0.443440   0.101073   4.387 1.15e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 252.84  on 20  degrees of freedom
## Residual deviance: 191.99  on 18  degrees of freedom
## AIC: 302.05
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_1)

#MODELO 2
modelo_2<- glm(PERROS.ENC ~ PERROS.GSV +  offset(log(KILOMETROS)) ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_2)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.8583  -1.6590  -0.9931   1.4215   6.2544  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  2.907429   0.095833  30.338   <2e-16 ***
## PERROS.GSV  -0.005780   0.002818  -2.051   0.0403 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 201.10  on 20  degrees of freedom
## Residual deviance: 196.87  on 19  degrees of freedom
## AIC: 304.94
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_2)

#MODELO 3
modelo_3<- glm(PERROS.ENC ~ PERROS.GSV +  AREA ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_3)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV + AREA, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.6207  -3.0748  -0.1727   1.8811   6.5866  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 2.655129   0.100593  26.395  < 2e-16 ***
## PERROS.GSV  0.012137   0.002856   4.249 2.14e-05 ***
## AREA        0.004808   0.000888   5.414 6.16e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 252.84  on 20  degrees of freedom
## Residual deviance: 184.84  on 18  degrees of freedom
## AIC: 294.91
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_3)

#MODELO 4
modelo_4<- glm(PERROS.ENC ~ PERROS.GSV +  offset(log(AREA)) ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_4)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV + offset(log(AREA)), family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.8437  -2.6414   0.7448   1.7920   6.4340  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -0.979555   0.090067 -10.876   <2e-16 ***
## PERROS.GSV   0.003607   0.002610   1.382    0.167    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 206.34  on 20  degrees of freedom
## Residual deviance: 204.44  on 19  degrees of freedom
## AIC: 312.51
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_4)

#MODELO 5
modelo_5<- glm(PERROS.ENC ~ PERROS.GSV + KILOMETROS + AREA ,
               family = poisson(link = "log"), data = PERROS_LIB.ACCE.1)

summary(modelo_5)
## 
## Call:
## glm(formula = PERROS.ENC ~ PERROS.GSV + KILOMETROS + AREA, family = poisson(link = "log"), 
##     data = PERROS_LIB.ACCE.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.1460  -2.8469  -0.1587   1.3450   6.2746  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  2.4897019  0.1169770  21.284  < 2e-16 ***
## PERROS.GSV  -0.0016077  0.0054817  -0.293  0.76930    
## KILOMETROS   0.3084564  0.1056763   2.919  0.00351 ** 
## AREA         0.0039834  0.0009616   4.143 3.43e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 252.84  on 20  degrees of freedom
## Residual deviance: 176.10  on 17  degrees of freedom
## AIC: 288.16
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_5)

MODELO PARA PERROS LIBRE ACCESO ENCUESTAS Y/O PERROS QUE PASEAN SIN CORREA Y PERROS STREET VIEW

#MODELO 6
modelo_6<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_6)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV, family = poisson(link = "log"), 
##     data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.3686  -2.7602  -0.8446   2.2026   5.9767  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 3.491775   0.067137   52.01   <2e-16 ***
## PERROS.GSV  0.019605   0.001946   10.08   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 335.75  on 20  degrees of freedom
## Residual deviance: 235.99  on 19  degrees of freedom
## AIC: 360.7
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_6)

#MODELO 7
modelo_7<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV + KILOMETROS ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_7)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV + KILOMETROS, family = poisson(link = "log"), 
##     data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -6.282  -2.128  -1.031   2.801   5.426  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  3.203747   0.083179  38.516  < 2e-16 ***
## PERROS.GSV  -0.001206   0.003874  -0.311    0.756    
## KILOMETROS   0.439367   0.071495   6.145 7.98e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 335.75  on 20  degrees of freedom
## Residual deviance: 196.74  on 18  degrees of freedom
## AIC: 323.45
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_7)

#MODELO 8
modelo_8<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV +  offset(log(KILOMETROS)) ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_8)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -5.241  -2.050  -1.242   2.067   7.785  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  3.542194   0.068317  51.849   <2e-16 ***
## PERROS.GSV  -0.003871   0.001987  -1.948   0.0514 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 201.22  on 20  degrees of freedom
## Residual deviance: 197.41  on 19  degrees of freedom
## AIC: 322.13
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_8)

#MODELO 9
modelo_9<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV +  AREA ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_9)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV + AREA, family = poisson(link = "log"), 
##     data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.3927  -2.7297  -0.8545   2.1744   5.9766  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  3.4970345  0.0718723  48.656   <2e-16 ***
## PERROS.GSV   0.0197821  0.0021305   9.285   <2e-16 ***
## AREA        -0.0001465  0.0007132  -0.205    0.837    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 335.75  on 20  degrees of freedom
## Residual deviance: 235.95  on 18  degrees of freedom
## AIC: 362.66
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_9)

#MODELO 10
modelo_10<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV +  offset(log(AREA)) ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_10)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV + offset(log(AREA)), 
##     family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -10.9614   -0.5849    0.9686    2.8965    7.4785  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -0.336325   0.064137  -5.244 1.57e-07 ***
## PERROS.GSV   0.005242   0.001839   2.851  0.00436 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 473.20  on 20  degrees of freedom
## Residual deviance: 465.13  on 19  degrees of freedom
## AIC: 589.85
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_10)

#MODELO 11
modelo_11<- glm(PERROS.ENC.SIN.COR ~ PERROS.GSV + KILOMETROS + AREA ,
               family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)

summary(modelo_11)
## 
## Call:
## glm(formula = PERROS.ENC.SIN.COR ~ PERROS.GSV + KILOMETROS + 
##     AREA, family = poisson(link = "log"), data = PERROS_SIN.CORREA.1)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -5.128  -2.350  -1.226   2.732   5.330  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  3.228194   0.084462  38.221  < 2e-16 ***
## PERROS.GSV  -0.002116   0.003893  -0.544  0.58670    
## KILOMETROS   0.516891   0.077343   6.683 2.34e-11 ***
## AREA        -0.002191   0.000824  -2.659  0.00783 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 335.75  on 20  degrees of freedom
## Residual deviance: 189.32  on 17  degrees of freedom
## AIC: 318.03
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_11)

MODELO PARA POBLACION TOTAL PERROS ENCUESTAS Y PERROS STREET VIEW

#MODELO 12
modelo_12<- glm(PERROS.ENC.TOT ~ PERROS.GSV,
               family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_12)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV, family = poisson(link = "log"), 
##     data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -12.0533   -2.7986   -0.5576    2.7440    8.7241  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  4.49807    0.04155  108.25   <2e-16 ***
## PERROS.GSV   0.01742    0.00122   14.28   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 803.99  on 20  degrees of freedom
## Residual deviance: 603.58  on 19  degrees of freedom
## AIC: 748.33
## 
## Number of Fisher Scoring iterations: 4
#plots residuos
par(mfrow=c(2,2))
plot(modelo_12)

#MODELO 13
modelo_13<- glm(PERROS.ENC.TOT ~ PERROS.GSV + KILOMETROS ,
               family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_13)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV + KILOMETROS, family = poisson(link = "log"), 
##     data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -13.5158   -2.5869   -0.3299    3.2437    7.0984  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  4.200512   0.051832   81.04   <2e-16 ***
## PERROS.GSV  -0.003845   0.002419   -1.59    0.112    
## KILOMETROS   0.450237   0.044715   10.07   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 803.99  on 20  degrees of freedom
## Residual deviance: 498.05  on 18  degrees of freedom
## AIC: 644.8
## 
## Number of Fisher Scoring iterations: 4
#plots residuos
par(mfrow=c(2,2))
plot(modelo_13)

#MODELO 14
modelo_14<- glm(PERROS.ENC.TOT ~ PERROS.GSV +  offset(log(KILOMETROS)) ,
               family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_14)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV + offset(log(KILOMETROS)), 
##     family = poisson(link = "log"), data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -11.8924   -3.2150   -0.6327    3.0180    6.4684  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  4.551463   0.042297 107.607  < 2e-16 ***
## PERROS.GSV  -0.006156   0.001247  -4.938 7.87e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 489.89  on 20  degrees of freedom
## Residual deviance: 465.38  on 19  degrees of freedom
## AIC: 610.12
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_14)

#MODELO 15
modelo_15<- glm(PERROS.ENC.TOT ~ PERROS.GSV +  AREA ,
               family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_15)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV + AREA, family = poisson(link = "log"), 
##     data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -7.416  -3.853  -2.095   3.359   8.402  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  4.670558   0.045297  103.11   <2e-16 ***
## PERROS.GSV   0.023605   0.001399   16.87   <2e-16 ***
## AREA        -0.005226   0.000519  -10.07   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 803.99  on 20  degrees of freedom
## Residual deviance: 490.51  on 18  degrees of freedom
## AIC: 637.25
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_15)

#MODELO 16
modelo_16<- glm(PERROS.ENC.TOT ~ PERROS.GSV +  offset(log(AREA)) ,
                family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_16)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV + offset(log(AREA)), 
##     family = poisson(link = "log"), data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -21.0423    0.3793    4.8808    6.6599   10.8915  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 0.662835   0.039761  16.671  < 2e-16 ***
## PERROS.GSV  0.003284   0.001155   2.844  0.00446 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 1788.5  on 20  degrees of freedom
## Residual deviance: 1780.5  on 19  degrees of freedom
## AIC: 1925.2
## 
## Number of Fisher Scoring iterations: 5
par(mfrow=c(2,2))
plot(modelo_16)

#MODELO 17
modelo_17<- glm(PERROS.ENC.TOT ~ PERROS.GSV + KILOMETROS + AREA ,
                family = poisson(link = "log"), data = PERROS_TOTAL.1)

summary(modelo_17)
## 
## Call:
## glm(formula = PERROS.ENC.TOT ~ PERROS.GSV + KILOMETROS + AREA, 
##     family = poisson(link = "log"), data = PERROS_TOTAL.1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.0703  -2.5031  -0.3175   2.1245   6.9463  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  4.2770293  0.0540966  79.063  < 2e-16 ***
## PERROS.GSV  -0.0079275  0.0024511  -3.234  0.00122 ** 
## KILOMETROS   0.7893866  0.0504341  15.652  < 2e-16 ***
## AREA        -0.0096618  0.0006601 -14.637  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 803.99  on 20  degrees of freedom
## Residual deviance: 229.45  on 17  degrees of freedom
## AIC: 378.2
## 
## Number of Fisher Scoring iterations: 4
par(mfrow=c(2,2))
plot(modelo_17)