You are currently browsing the category archive for the ‘Blog’ category.

Kvietimas adresuojamas visiems matematikos ir informatikos fakulteto studentams turintiems statistikos žinių ir norintiems jas išbandyti praktikoje. Praeitais metais fakultete vyko duomenų analizės renginys Political science data dive. Jo metu buvo analizuojami rinkimų duomenys. Šiais metais kolegos iš TSPMI siūlo kažką panašaus — analizuoti įvairius politinius duomenis statistiniais metodais. Jiems reikėtų pagalbos su statistika. Manau tai puikus būdas išbandyti savo jėgas su realiais duomenimis ir darbą komandoje. Susidomėjusius prašome rašyti elektroniniu paštu ar man (zemlys at gmail dot com) arba Ainei Ramonaitei (aine dot ramonaite at tspmi dot vu dot lt>).

Sukūriau naują blogą: http://myliuduomenis.lt. Įrašai daromi su Rstudio naudojant knitr. Puslapio kodą galima rasti čia. Į kažką panašaus galbūt numigruosiu ir šitą blogą.

Bit of a major rewrite. Added formula interface, convergence testing and support for different optimisation algorithms. Documentation needs to be updated, but all the examples and demo work.

Downloads in the usual place.

Nusiunčiau savo postą 15min.lt, paredagavau, įdėjo.

Vakar lrytas.lt radau šį straipsnį. Jame ekonomikos mokslų daktaras Algirdas Butkevičius teigia, kad

stebima neigiama BVP pokyčių tendencija kelia rimtą nerimą: BVP jau ir per ketvirtąjį praėjusių metų ketvirtį smuko 5,5 proc.

Toliau yra klausiama:

„Jeigu 2011 m. ketvirtąjį ketvirtį BVP sudarė 27 571,6 milijardo litų, o 2012 m. pirmąjį ketvirtį jis tesiekė 25 235,3 milijardo litų, tai kaip galima kalbėti apie krizės stabilizavimą ir stebuklingą ekonomikos atsigavimą?“

Bei reziumuojama

Socialdemokratų lyderį stebina statistikos duomenų interpretacijos, nors ruošiantis rinkimams valdantiesiems svarbu užliūliuoti rinkėjų budrumą ir uždėti jiems rožinius akinius.

Susirūpinęs Lietuvos likimu pasiėmiau realaus BVP duomenis iš statistikos departamento:
Realus Lietuvos BVP

Pažiūrėjus į grafiką matosi, kad Lietuvos BVP beveik visados krinta ketvirtą ir pirmą metų ketvirčiais. Atskirai pažiūrėjus ketvirto ketvirčio augimus nuo 1995 metų matosi toks vaizdas:
IV ketvirčio augimas palyginus su III ketvirčiu kiekvienais metais

Visi augimai neigiami. Taigi minėtos tendencijos kartojasi jau 17 metų, nepriklausomai nuo krizių, ekonomikos atsigavimų ir kitų faktorių.

Šis reiškinys vadinamas sezoniškumu ir keista kad ekonomikos mokslų daktaras šio reiškinio nežino, bei stebisi statistikos duomenų interpetacijomis, kai jo paties pasvarstymai yra ne kas kita kaip klaidinga duomenų interpretacija.

Dar keisčiau, kad kitas ekonomikos mokslų daktaras Povilas Gylys, pasirenka kaltinti Statistikos departamentą visuomenės klaidinimu, bet apie savo kolegos (moksline prasme) klaidingus išvedžiojimus nutyli.

Added empirical example. Run demo("okun","midasr") to see. Also changed function hAh.test. Now only restricted model must be supplied, unrestricted is calculated automatically. Downloads in the usual place.

I’ve decided to release a new version of midasr package. In this package the support is added for numerical gradient, exogenous variables and more complicated lag structure. The downloads are in the usual place.

I’ve created my first R package midasr. Phew, documentation took as much time as actual coding. On the other hand the code was provided by my collaborator Virmantas Kvedaras. My task was to clean up the code and prepare R package.

The package is for testing MIDAS regressions. This is a first release, so the functionality is still very basic.

Šiais metais vėl organizuojamas MTRT. Gal net ir bus įtrauktas į MIDI programą. Norintys dalyvauti registruokitės čia, ty palikite komentarą. Tikslus laikas ir vieta bus pranešti vėliau.

So I’m getting my daily fix of r-bloggers.com and I encounter this post. Hey, I figure, if polish can draw his country flag using R, why can’t lithuanian do it? 🙂 It should be easy, as cut and paste, right? It turned out not so easy in the end, but not that hard either. Here is the final result. The R code with the description of the process is below.

The hardest part was to get the map of the Lithuania. It turns out that the maps package used to obtain the map of Poland has out-dated maps, circa 1980. There was no Lithuania at that time, curse you Soviets 🙂

After searching a bit, I did not find the R package with the updated map, but I found out how to get more recent map into R. First you need to download the following file from this site. The simplified map from this site is in R package maptools, but it seems the full version is not available as an R package.
You have to unzip the file and then you import it in the following way:

library(maptools)
world<-readShapeSpatial("~/Downloads/TM_WORLD_BORDERS-0.3/TM_WORLD_BORDERS-0.3.shp")

lithuania<-world[world$ISO2=="LT",]
@

To get into more readable format the following lines are necessary. I found them on github ggplot2 page. Thanks to Haddley Wickham:

library(gpclib)
gpclibPermit()
library(ggplot2)
lt<-fortify(lithuania,region="ISO2")

> head(lt)
      long      lat order  hole piece group id
1 25.00000 56.29555     1 FALSE     1  LT.1 LT
2 25.07250 56.21915     2 FALSE     1  LT.1 LT
3 25.08111 56.21055     3 FALSE     1  LT.1 LT
4 25.09694 56.20110     4 FALSE     1  LT.1 LT
5 25.10611 56.19721     5 FALSE     1  LT.1 LT
6 25.13388 56.18888     6 FALSE     1  LT.1 LT

As you see in the end we get the data.frame with longitude and lattitudes and additional info. The relevant additional info in our case is in pieces column. Lithuania consists of 2 separate pieces: the mainland and Curonian spit. Since only part of Curonian spit belongs to Lithuania, it is not connected to Lithuanian mainland. So in the map it looks like an island, when in fact it is not.

The points in the data.frame are ordered, so you can plot them immediately:

plot(lt1,axes=FALSE,xlab="",ylab="",type="l")
polygon(lt2)

Now we have the shape, we need only to fill in the colors. To do that we need to divide the 2 polygons into 3 pieces with equal heights.

It is easy to cut the polygon into 2 pieces along the horizontal line. Here are the functions I used to do that:

x.mid <- function(x1, x2, y.mid) {
      c(x1[1] + ((x2[1] - x1[1]) / (x2[2] - x1[2])) * (y.mid - x1[2]),y.mid)
}

cut.poly.in.half <- function(xy,cut.y.point) {
    cond <- xy[,2]>cut.y.point
    if(!is.matrix(xy))xy <- as.matrix(xy)
    if(sum(cond)==0 | sum(!cond)==0) {
        warning("Whole polygon is either below orabove the cut-line, original polygon is returned")
        return(xy)
    }
    
    dcond <- diff(cond)
    if(sum(dcond)==0) {
        
        tmp<- sort(c(which.min(diff(cond)),which.max(diff(cond))))
        start.y <- tmp[1]
        end.y <- tmp[2]


        start <- x.mid(xy[start.y,],xy[start.y+1,],cut.y.point)    
        
        end <- x.mid(xy[end.y,],xy[end.y+1,],cut.y.point)
  
        top <- rbind(xy[1:start.y,],start,end,xy[(end.y+1):nrow(xy),])
        bottom <- rbind(start,xy[(start.y+1):end.y,],end)
        if(top[1,2]<cut.y.point) {
            tmp <- top
            top <- bottom
            bottom <- tmp
        }
        list(top=top,bottom=bottom)
    }
    
}

I borrowed some code from Bogumił Kamiński. The function just adds two points to the array of points. It checks whether the polygon is cuttable, i.e. the horizontal line goes through the middle. It also assumes, that the line cuts the the polygon into 3 pieces, if we imagine the polygon as the line with the start and an end, which basically what polygon is in R. It is easy to add the code for the case of 2 pieces, but this case is rare, and I was lazy, so there you go:).

Now let us start the cutting:

##We need to cut the polygon of all Lithuania into three equal parts
##First cut out the top part
aa <- cut.poly.in.half(as.matrix(lt1),cut.points[2])
##Now divide the remaining part into halves
bb <- cut.poly.in.half(aa$bottom,cut.points[1])
##Curonian spit part only needs to be cut into two parts
cc <- cut.poly.in.half(lt2,cut.points[2])
@

Now get the colors of Lithuanian flag, and do the final step:

##Colors of Lithuanian flag, from top to bottom.
##Gzr stands for geltona, zalia, raudona: yellow, green, red in lithuanian.
gzr <- c("#fdb913","#006a44","#c1272d")
##Colour the top 
polygon(aa$top,col=gzr[1])
polygon(cc$top,col=gzr[1])
##Colour the middle
polygon(bb$top,col=gzr[2])
polygon(cc$bottom,col=gzr[2])
##Colour the bottom
polygon(bb$bottom,col=gzr[3])

Using this code it is more or less easy to replicate this exercise for other countries which have flags with where colours are horizontal and there are no additional structures. Flags with vertical colours should be easy too. But flags with more structure as flag of Finland, or United Kingdom would be naturally harder.

Naujausi komentarai

vzemlys apie Rožiniai akiniai
Audrius apie Rožiniai akiniai
Karl apie Time series data aggregation u…
Vytautas Astrauskas apie Matematinio teksto rinkimo tur…
Auksinis kardas apie Drawing national flags on maps…
2023 m. birželio mėn.
Pr A T K Pn Š S
 1234
567891011
12131415161718
19202122232425
2627282930